Re: VBA Macro Code Isna/Vlookup Error
You're trying to tell VBA to post the value of the active cell to the relevant range if it can't find it in that range. The problem is that if it can't actually find it in that range, it never gets past the "If" test in the first place. The issue is that you're using worksheet formula logic in VBA, but what is returned in the case of an error in a worksheet, isn't the same as what is returned in the case of an error in your VBA code.
You just need a few simple error handling lines so that VBA can query whether or not a calculation is an error, and if so then act on it
Sub findmissingitems()
Dim x
Sheets("Paste Inventory Count").Select
Range("c1").Select
Do
'//Tell VBA to ignore an error and continue (ie if it can't find the value)
On Error Resume Next
'//Assign the result of your calculation to a variable that VBA can query
x = WorksheetFunction.VLookup(ActiveCell.Value, _
Sheets("SKU Reference").Range("A:A"), 1, False)
'//if Vlookup throws up an error, eg can't find the value, then paste it into the required column
If Err <> 0 Then
Rows(ActiveCell.Row).Select
Selection.Copy
Sheets("SKU Reference").Select
LastRowColA = Range("A65536").End(xlUp).Row
Selection.Paste
Else
ActiveCell.Offset(1, 0).Range("A1").Select
End If
'//resets to normal error handling
On Error GoTo 0
Loop Until IsEmpty(ActiveCell)
End Sub
Display More
By the way, you've used VLookup to match a value in a one column range, which works fine. But also have a look at the Match function, which is designed specifically to do that