ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Vlookup function macro (https://www.excelbanter.com/excel-discussion-misc-queries/229174-vlookup-function-macro.html)

jack

Vlookup function macro
 
i have a series of tables that i need to select from, Below is a sample of
the if statement i have written. I need to copy this to multiple cells. Is
there a way to write a function macro to do the same thing?

=IF($O18=5,VLOOKUP(RateSheetDate,Table_PF_G5_T1,4) ,IF($O18=6,VLOOKUP(RateSheetDate,Table_PF_G6_T1,4) ,IF($O18=7,VLOOKUP(RateSheetDate,Table_PF_G7_T1,4) ,IF($O18=8,VLOOKUP(RateSheetDate,Table_PF_G8_T1,4) ,0))))

Elkar

Vlookup function macro
 
You may not need a macro. See if this works for you:

=VLOOKUP(RateSheetDate,INDIRECT("Table_PF_G"&$O18& "_T1"),4)

The INDIRECT function allows you to create a dynamic range reference based
upon the value in cell O18.

HTH
Elkar


"Jack" wrote:

i have a series of tables that i need to select from, Below is a sample of
the if statement i have written. I need to copy this to multiple cells. Is
there a way to write a function macro to do the same thing?

=IF($O18=5,VLOOKUP(RateSheetDate,Table_PF_G5_T1,4) ,IF($O18=6,VLOOKUP(RateSheetDate,Table_PF_G6_T1,4) ,IF($O18=7,VLOOKUP(RateSheetDate,Table_PF_G7_T1,4) ,IF($O18=8,VLOOKUP(RateSheetDate,Table_PF_G8_T1,4) ,0))))


jack

Vlookup function macro
 
Works great - Thanks

"Elkar" wrote:

You may not need a macro. See if this works for you:

=VLOOKUP(RateSheetDate,INDIRECT("Table_PF_G"&$O18& "_T1"),4)

The INDIRECT function allows you to create a dynamic range reference based
upon the value in cell O18.

HTH
Elkar


"Jack" wrote:

i have a series of tables that i need to select from, Below is a sample of
the if statement i have written. I need to copy this to multiple cells. Is
there a way to write a function macro to do the same thing?

=IF($O18=5,VLOOKUP(RateSheetDate,Table_PF_G5_T1,4) ,IF($O18=6,VLOOKUP(RateSheetDate,Table_PF_G6_T1,4) ,IF($O18=7,VLOOKUP(RateSheetDate,Table_PF_G7_T1,4) ,IF($O18=8,VLOOKUP(RateSheetDate,Table_PF_G8_T1,4) ,0))))



All times are GMT +1. The time now is 03:47 AM.

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