ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   vlook on different tabs based on value (https://www.excelbanter.com/excel-worksheet-functions/263183-vlook-different-tabs-based-value.html)

jatman

vlook on different tabs based on value
 
good day,

i have the following so far in my macro:

....
supcode = Range("B4").Value
....
If supcode = "CLI" Then
ActiveCell.Offset(0, 4) = "=VLOOKUP(RC[-4], '[Order
Generator.xlsm]CLI'!C2:C4,2,FALSE)"
....

right now i have this code repeated several times for each supcode that may
exist and i am usingn an if statement for each possible "supcode". i would
like to replace all the if statements, and change the "CLI" to use the
"supcode" value.

how do i get the "supcode" value into the vlookup code?

thank you,

jat

Luke M[_4_]

vlook on different tabs based on value
 
'All on one line
ActiveCell.Offset(0, 4) = "=VLOOKUP(RC[-4], '[Order Generator.xlsm]" &
supcode & "'!C2:C4,2,FALSE)"

--
Best Regards,

Luke M
"jatman" wrote in message
...
good day,

i have the following so far in my macro:

...
supcode = Range("B4").Value
...
If supcode = "CLI" Then
ActiveCell.Offset(0, 4) = "=VLOOKUP(RC[-4], '[Order
Generator.xlsm]CLI'!C2:C4,2,FALSE)"
...

right now i have this code repeated several times for each supcode that
may
exist and i am usingn an if statement for each possible "supcode". i
would
like to replace all the if statements, and change the "CLI" to use the
"supcode" value.

how do i get the "supcode" value into the vlookup code?

thank you,

jat





All times are GMT +1. The time now is 11:03 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com