ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   creating a range reference from cell values (https://www.excelbanter.com/excel-discussion-misc-queries/153800-creating-range-reference-cell-values.html)

Robin Krupp

creating a range reference from cell values
 
I am try to do a vlookup where the range is built from cell values ex.

=VLOOKUP($K$16,TRIM(B17&"!"&"A1:L32"),3,FALSE)

b17 contains the sheet name

but gives me a #value! error

but works if the range is hard coded

But I really want to build the range dynamiclly

Can anyone help ???
thanks

Bob Umlas

creating a range reference from cell values
 
=VLOOKUP($K$16,INDIRECT(B17&"!A1:L32")3,FALSE)

"Robin Krupp" wrote in message
...
I am try to do a vlookup where the range is built from cell values ex.

=VLOOKUP($K$16,TRIM(B17&"!"&"A1:L32"),3,FALSE)

b17 contains the sheet name

but gives me a #value! error

but works if the range is hard coded

But I really want to build the range dynamiclly

Can anyone help ???
thanks




Elkar

creating a range reference from cell values
 
You'll need to use the INDIRECT function. You could basically just replace
TRIM with INDIRECT in your formula and it should work.

=VLOOKUP($K$16,INDIRECT(B17&"!A1:L32"),3,FALSE)

Not sure why you're using the TRIM function in the first place, unless B17
may contain extra spaces? If so, just place B17 in the TRIM function.
....INDIRECT(TRIM(B17)&"!...

HTH,
Elkar


"Robin Krupp" wrote:

I am try to do a vlookup where the range is built from cell values ex.

=VLOOKUP($K$16,TRIM(B17&"!"&"A1:L32"),3,FALSE)

b17 contains the sheet name

but gives me a #value! error

but works if the range is hard coded

But I really want to build the range dynamiclly

Can anyone help ???
thanks


Dave Peterson

creating a range reference from cell values
 
=VLOOKUP($K$16,indirect("'" & TRIM(B17) &"'!"&"A1:L32"),3,FALSE)

Are you sure you need the =trim() portion?

Robin Krupp wrote:

I am try to do a vlookup where the range is built from cell values ex.

=VLOOKUP($K$16,TRIM(B17&"!"&"A1:L32"),3,FALSE)

b17 contains the sheet name

but gives me a #value! error

but works if the range is hard coded

But I really want to build the range dynamiclly

Can anyone help ???
thanks


--

Dave Peterson

T. Valko

creating a range reference from cell values
 
Try it like this:

=VLOOKUP($K$16,INDIRECT("'"&TRIM(B17)&"'!A1:L32"), 3,0)

--
Biff
Microsoft Excel MVP


"Robin Krupp" wrote in message
...
I am try to do a vlookup where the range is built from cell values ex.

=VLOOKUP($K$16,TRIM(B17&"!"&"A1:L32"),3,FALSE)

b17 contains the sheet name

but gives me a #value! error

but works if the range is hard coded

But I really want to build the range dynamiclly

Can anyone help ???
thanks





All times are GMT +1. The time now is 08:20 PM.

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