countryfan_nt
Well-known Member
- Joined
- May 19, 2004
- Messages
- 758
Hello friends, hope all is well!
Please help me edit/fix the below code:
It is supposed to go through A2 & below till The cell is blank (Looping A2 to blank cell)
The code has a vlookup; I wish to have an IF statement: if vlookup result <> the cell value in B2 & below, then the clear contents of A2 & below.
if the lookup matches go to next cell of A.
Your kind help is needed and really appreciated in advance.
Please help me edit/fix the below code:
It is supposed to go through A2 & below till The cell is blank (Looping A2 to blank cell)
The code has a vlookup; I wish to have an IF statement: if vlookup result <> the cell value in B2 & below, then the clear contents of A2 & below.
if the lookup matches go to next cell of A.
Your kind help is needed and really appreciated in advance.
Code:
Sub test()
Dim x As String
Sheets("sheet1").Select
Range("A2").Select
Do
If x = Application.WorksheetFunction.VLookup(ActiveCell.Value, Worksheets("sheet1").Range("J4:K11"), 2, False) <> ActiveCell.Offset(0, 1) Then
ActiveCell.ClearConents
Else
ActiveCell.Value = x
End If
ActiveCell.Offset(1, 0).Activate
Loop Until IsEmpty(ActiveCell.Value)
End Sub