Error Handling in VLOOKUP with VBA

sahaider

New Member
Joined
May 30, 2014
Messages
35
Hello ,
I have the following VBA code that includes VLOOKUP.

I am trying to include error trapping in the code so that when Vlookup returns #N/A write the code writes "Missing" in those cells.

VBA Code:
lastRow = Worksheets("LTE_Best Server by RSRP").Cells.SpecialCells(xlCellTypeLastCell).Row
With Worksheets("LTE_Best Server by RSRP")
For r1 = 2 To lastRow

.Range("G" & r1) = Application.WorksheetFunction.IfNa(VLookup(CStr(.Range("F", r1)), Worksheets("ALL 4G Hierarchy").Range("E2:J125000"), 5, False), "Missing")

Next

End With

But i am getting Sub/Function not defined for VLOOKUP when I run the code.

Can't figure out what is wrong in the code.
 
See posts 8 & 9, Peter already spotted the problem & I've corrected it in post#9
 
Upvote 0

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,861
Messages
6,121,971
Members
449,059
Latest member
oculus

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top