View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Ken Hudson Ken Hudson is offline
external usenet poster
 
Posts: 186
Default VB Lookup Syntax

Thanks Dave.
--
Ken Hudson


"Dave Peterson" wrote:

dim res as variant
dim LookUpRng as range
dim myVal as variant

set lookuprng = thisworkbook.sheets(2).range("a1:d300")

myval = activesheet.range("d1").value
res = application.vlookup(myval, lookuprng, 3, false)

if iserror(res) then
'what should happen
Res = "not found!"
end if

activesheet.name = res



Ken Hudson wrote:

Hi,
Need help with the correct syntax for Vlookup in VB.

ActiveSheet.Name =
Application.WorksheetFunction.VLookup(D1,[ThisWorkbook.Name]ThisWorkbook.Sheets(2).Name!A1:D300,3,False)

isn't correct.


--

Dave Peterson