I had trouble getting my hlookup to work, and whilst trying a few things, I wrote this. I'm glad it works, but I always like to know why, and I just can't think this through in my head.
It's the If Error line. Can someone explain what it's doing? I know it's probably simple, but I'm still fairly new to the whole VB thing. Great fun though!!!
BTW, ReceiptsCol and LookupRange are dimmed early on in my sub.
It's the If Error line. Can someone explain what it's doing? I know it's probably simple, but I'm still fairly new to the whole VB thing. Great fun though!!!
BTW, ReceiptsCol and LookupRange are dimmed early on in my sub.
Code:
On Error Resume Next
If Error = Sheet21.Cells(r, 1) = WorksheetFunction.HLookup(Sheet21.Cells(r, 1), LookupRange, 1, False) Then
On Error GoTo 0
Sheet3.Columns(ReceiptsCol).EntireColumn.Insert
End If