View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
p45cal[_36_] p45cal[_36_] is offline
external usenet poster
 
Posts: 1
Default vlookup VBA code


Very likely because what it's looking for isn't to be found.
I tried this:
ActiveCell.Value = WorksheetFunction.VLookup(Cells(ActiveCell.Row,
"A"), srccom, 5, 0)
and it worked, but then gave the error you describe if what was sought
didn't exist.
Try the likes of this:Dim srccom As Range
Set srccom = ThisWorkbook.Worksheets("Sheet1").Range("F1:J100")
xxx = Empty
On Error Resume Next
xxx = WorksheetFunction.VLookup(Cells(ActiveCell.Row, "A"), srccom, 5,
0)
On Error GoTo 0 'cancels the On Error Resume Next
If Not IsEmpty(xxx) Then ActiveCell.Value = xxx


--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=126806