![]() |
VB Lookup Syntax
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. |
VB Lookup Syntax
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 |
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 |
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 |
All times are GMT +1. The time now is 08:27 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com