2017-09-12 3 views
-2
Rows | Ref1 | Ref2 | Ref3| Final Ref  
3  | aa | bb | cc | aa  
3  | aa | bb | cc | bb  
3  | aa | bb | cc | cc  
2  | as | al |  | as  
2  | as | al |  | al 

아래의 vba는 '최종 참조'열의 생성을 자동화합니다. 이 값은 다른 열에서 가져옵니다. 예 : 동일한 참조가있는 3 개의 중복 행이 있습니다. 첫 번째 행의 Ref1, 두 번째 행의 Ref2 및 세 번째 행의 Ref3이 필요합니다. 그런 다음 중복되는 다음 2 행에 대해 첫 번째 행의 Ref1과 두 번째 행의 Ref2가 필요합니다.열의 데이터를 루프로 새 열로 복사

이것은 내가 지금까지 가지고있는 것입니다. 가장 긴 행을 기준으로 범위를 동적으로 지정하고 싶습니다. 나는 그 순간 값을 입력해야한다. 사용 된 범위를 선택하려면 vba가 별도로 있지만 두 가지를 결합하는 방법을 모르겠습니다. 미리 감사드립니다.

Sub CopyRowPasteRef() 
Dim rngToConvert As Range 
Dim rngRow As Range 
Dim rngCell As Range 

'incremental step to keep track of rows 
Dim writeRow As Integer 
writeRow = 1 

'The entire range we are converting 
Set rngToConvert = Sheets("Sheet11").Range("A1:E6") 

'Loop through each row 
For Each rngRow In rngToConvert.Rows 

    'Loop through each cell (field) 
    For Each rngCell In rngRow.Cells 

     'ignore that first row 
     If rngCell.Column > 1 And rngCell.Value <> "" Then 

      'Write that row header 
      Sheets("Sheet12").Cells(writeRow, 1).Value = rngRow.Cells(1, 1) 

      'Write this non-null value 
      Sheets("Sheet12").Cells(writeRow, 2).Value = rngCell.Value 

      'Increment Counter 
      writeRow = writeRow + 1 
     End If 
    Next rngCell 
Next rngRow 
End Sub 

사용 된 셀을 기반으로하는 동적 범위를 통합하려면 어떻게하면 아래의 vba에 vba를 추가 할 수 있습니까?

Range("A1").Resize(Cells.Find(What:="*", SearchOrder:=xlRows, _ 
    SearchDirection:=xlPrevious, LookIn:=xlValues).Row, _ 
    Cells.Find(What:="*", SearchOrder:=xlByColumns, _ 
    SearchDirection:=xlPrevious, LookIn:=xlValues).Column).Select 
+5

우리는 당신을 위해 코드는하지만, 우리는 개인의 문제가 당신을 도울 수 없으며 질문. – BobtimusPrime

+0

google - 중복 제거 –

+0

데이터를 인라인으로 작성해 주셔서 감사합니다. 어떻게해야할지 모릅니다. – user8598619

답변

1

E2에 넣고 아래로 복사 : 당신이 그것에게 기회를 주면

=INDEX(B2:D2,COUNTIFS($B$1:B2,"=" &B2,$C$1:C2,"=" & C2,$D$1:D2,"=" &D2)) 

enter image description here

+0

고맙습니다! – user8598619

관련 문제