i have the following code:
- It is supposed to go into a sheet named “Flash” and get the i-th 2 digit numeric value and retrieve the value in a column offset 4 to the right of the Activecell.
- Then swap to a sheet named “Sheet1” on the same workbook and use a Vertical Lookup function to find the retrieved value and return the value 4 columns to the right of that cell.
However when i run the script below it stops working at :
MsgBox (ActiveSheet.VLookup(LookFor, "A:A", 4, True))
and VBA throws error 438 object doesn't support this property or method
does anyone know why there’s an exception?
' Begin lookup :
Dim i As Integer, designator As String, LookFor As String
Flash.Activate
ActiveSheet.Range("C3").Select
For i = 3 To lastUsedCellInRow("C")
designator = "C" + CStr(i)
Dim cellVal As String
cellVal = ActiveSheet.Range(designator).Value()
If (Len(cellVal) <= 2 And IsNumeric(cellVal)) Then
LookFor = ActiveSheet.Range(designator).Offset(0, 4).Value()
RawData.Activate
MsgBox (ActiveSheet.VLookup(LookFor, "A:A", 4, True))
End If
Next i
You have several issues
Range("A:A")not"A:A"VLOOKUPrather thanLOOKUPthen as stated you need to be referring to a four column range ,Range("A:D")Sample code below for you to adapt
Follow-up
Yes, you could use
for this match
bu I think
Findis cleaner, ie