dimanche 29 mars 2015

Row matching between columns from two worksheets instead from one worksheet

Hi i tried and edit the following code i found.There is lots of different errors coming up. i hope to change to do the match the data from 2 worksheets instead of the active worksheet only. Advice on the code is appreciated . Thank you


Sub matching()


Dim A, B, Col, rw As Integer


Dim Sheet1, sheet2 As Range



A = WorksheetFunction.CountA(Range("A:A"))
B = WorksheetFunction.CountA(Range("B:B"))
If A > B Then _
Col = 2 Else Col = 1

rw = 2


nxtChk:


If Cells(rw, 1) <> "" And Cells(rw, 1) < Cells(rw, 2) Then Cells(rw, 2).Insert shift:=xlDown Else If Cells(rw, 2) <> "" And Cells(rw, 1) > Cells(rw, 2) Then Cells(rw, 1).Insert shift:=xlDown End If End If



If Cells(rows.Count, Col).End(xlUp).row + 1 = rw Then Exit Sub

rw = rw + 1


GoTo nxtChk End Sub


Aucun commentaire:

Enregistrer un commentaire