2017-12-22 1 views
1

열 A에 중복 값이있는 경우 Excel에서와 마찬가지로 True = False가 표시되는 코드를 작성했습니다. A1 = A2 우리는 강조 열에 복제가 있고 열 T에 같은 시간 값이 필요합니다.

내가 마지막 행을 찾는 방법 확실하지 오전, 그래서 난 T9000의 범위를 코딩,하지만 T3500, 또는 때때로 T15000까지 데이터가있을 수 A.

에 데이터가 마지막 행까지.

Range("A1:A5000").Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlYes 
ActiveCell.FormulaR1C1 = "Dup" 
Range("T2").Select 
ActiveCell.FormulaR1C1 = "=R[-1]C[-19]=RC[-19]" 
Range("T3").Select 
Selection.End(xlDown).Select 
Range("S1048576").Select 
Selection.End(xlUp).Select 
Range("T9000").Select 
Range(Selection, Selection.End(xlUp)).Select 
Selection.FillDown 
+0

내가 아주 확실하지 않다, 당신이 찾고있는 무엇. 열의 마지막 행을 식별하려면'lLastRow = ActiveSheet.Cells (Rows.Count, "B") End (xlUp) .Row' 코드를 사용하면됩니다. 컬럼을 적용하고 결과를 LONG 변수에 저장해야합니다 (정수는 ~ 32.000까지 작동합니다). – prextor

답변

0

세포 A1이면 Dup의 위치가 확실하지 않습니까? 나머지 코드는 마지막 행 변수를 사용하여 계약 할 수 있습니다.

lastRow = wsSource.Cells(wsSource.Rows.Count, "A").End(xlUp).Row 

계약 코드 :

Option Explicit 

Sub FindDups() 

    Dim wb As Workbook 
    Dim wsSource As Worksheet 
    Dim lastRow As Long 

    Set wb = ThisWorkbook      'Variable assignments 
    Set wsSource = wb.Worksheets("Sheet2") 

    lastRow = wsSource.Cells(wsSource.Rows.Count, "A").End(xlUp).Row 'find last row by coming from the bottom of the sheet and finding last used cell in column 

    With wsSource 
     .Range("A1").FormulaR1C1 = "Dup" 
     .Range("A1:A" & lastRow).Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlYes 
     .Range("T2:T" & lastRow).FormulaR1C1 = "=IF(RC[-19]=R[-1]C[-19],""Duplicate"", RC[-19])" 
    End With 

End Sub 
+0

감사합니다, 나는 아래에왔다 코드 지금은 "중복"Coumn T는 어디 값이 고유 한 지 내가 빈 셀로 Orignal 얻을 수 있도록 코드를 삽입해야 할 때 해당 셀을 받고 오전 dim matchFoundIndex 한 희미한 iCntr 한 lastRow = 범위 ("A65000"). 끝 (xlUp) 셀에만 iCntr를 들어 = 1 lastRow 으로하면 세포 (iCntr, 1) <> ""그럼 matchFoundIndex = WorksheetFunction.Match (세포 (iCntr, 1), 범위 ("A1 : A"및 lastRow)은 종료 다음 – Sachin

+0

경우 내가 아니다 종료되면, 0) iCntr <> matchFoundIndex 그런 다음 세포 (iCntr, 20) = "중복"경우 무슨 뜻인지 알 겠어. 그러나 편집이 원하는 것인지 확인하십시오. – QHarr

+0

나는 열 A의 값이 두 번 이상있는 곳에서 중복이라는 단어를 얻는다는 것을 의미합니다. 열의 값이 단일 인 원본을 얻으려면 어떻게해야합니까? 위의 코드를 검토하십시오. – Sachin

관련 문제