Hello - I am well versed with formulas but still a begginer with VBA so bear with me.
I am trying to write a Macro that performs a Vlookup using a value in Sheet1 against an array in Sheet 2.
There are three columns in sheet 1 - ProductCode, CodeFamily, CurrentInventory
I want the value of the function to drop the new inventory number (off the array in Sheet 2) in new Column D
Then after it returns that value I want in to autmatcally filter the differences between CurrentInventory (column C) and UpdatedInventory (column D)
Here is where I got so far - I am stuck on the Loop function and haven't performed an autofilter yet...
Sub Vlookup()
Dim lookFor As Range
Dim rng As Range
Dim found As Variant
Worksheets("Sheet1").Activate
Set lookFor = Sheets("Sheet1").Range("A2")
Set rng = Sheets("Sheet2").Columns("A:B")
ActiveCell.Offset(0, 0).Select
Do While Not IsEmpty(ActiveCell.Select)
On Error Resume Next
found = Application.VLookup(lookFor.Value, rng, 2, 0)
Sheets("sheet1").Range("d2").Active
ActiveCell.Value = found
Loop
On Error GoTo 0
End Sub
Bookmarks