Saria Ahmad
New Member
Hi folks, I am quite new to VBA. I need help in comparing the data in two columns. I want to bring similar data in same row and if nothing common is found I want to insert the blank row. I tried many ways but all in vain.
sample data file is attached below
Below is my code.
Looking forward for your valuable suggestions.
>>> use code - tags <<<
sample data file is attached below
Below is my code.
Looking forward for your valuable suggestions.
>>> use code - tags <<<
Code:
Sub compare()
Dim rng1 As Range
Dim rng2 As Range
Set rng1 = Range("A1:A11")
Set rng2 = Range("B1:B8")
If rng1.Value1 = rng2.Value2 Then
'both cells dont match.'
Else
Worksheets(1).Rows(1).Insert
End If
End Sub
Attachments
Last edited by a moderator: