Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 186
Default 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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
  #3   Report Post  
Posted to microsoft.public.excel.programming
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

  #4   Report Post  
Posted to microsoft.public.excel.programming
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
lookup help. lookup result based on data in 2 columns lcc Excel Worksheet Functions 3 April 6th 10 01:20 PM
LOOKUP & MATCH syntax ?? Bassman62 Excel Worksheet Functions 6 April 8th 09 05:22 AM
LOOKUP function syntax across a table? Marc Excel Worksheet Functions 6 March 25th 09 12:19 AM
Lookup : Syntax Error Steve_n_KC Excel Worksheet Functions 0 June 14th 07 07:59 PM
What is the syntax for referencing another sheet with 'lookup' ihenderson Excel Worksheet Functions 3 July 31st 06 12:05 PM


All times are GMT +1. The time now is 12:36 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"