Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
crazybass2
 
Posts: n/a
Default Using a cell reference of a sheet in Vlookup

I have a spreadsheet that performs vlookups from several other sheets. From
time to time new sheets are added and I would like to be able to change one
cell and have all the vlookups change to that sheet.

For example,

On sheet1 I have the following vlookups:

A10 =vlookup(D10,'My First Sheet'!A:D,4,false)
A11 =vlookup(D11,'My First Sheet'!A:D,4,false)
A12 =vlookup(D12,'My First Sheet'!A:D,4,false)
and so on...

I would like to have a cell on sheet1 that I can enter the name of the tab I
want to use. In the above case it would be "My First Sheet". If I changed
this cell to "My Second Sheet" I would want the above references lines to
become:

A10 =vlookup(D10,'My Second Sheet'!A:D,4,false)
A11 =vlookup(D11,'My Second Sheet'!A:D,4,false)
A12 =vlookup(D12,'My Second Sheet'!A:D,4,false)
and so on...

I have done this before using VBA, but I would like to do it without coding.

What I've tried is using the following:

A10 =vlookup(D10,"'" & $A$1 & "'!A:D",4,false)
A11 =vlookup(D11,,"'" & $A$1 & "'!A:D",4,false)
A12 =vlookup(D12,,"'" & $A$1 & "'!A:D",4,false)
and so on...

Where A1 would be where I type in a tab name.

This results in an error. Using the "Show Calculation Steps" tool I find
that the range reference in the vlookup still has quotation marks around it.
So instead of evaluating =vlookup(D10,'My Second Sheet'!A:D,4,false) it is
trying to evaluate =vlookup(D10,"'My Second Sheet'!A:D",4,false), which of
course doesn't work. Is there any way to remove the quotation marks, or any
other way of using a cell reference to a tab name in the vlookup function?

All help is much appreciated.

Mike
  #2   Report Post  
John Michl
 
Posts: n/a
Default

You can use the INDIRECT function to piece together your formula. Try
the following:

A10 = vlookup(D10,indirect(A1)&"!A:D",4,false)

- John Michl

  #3   Report Post  
Domenic
 
Posts: n/a
Default

You can use INDIRECT...

=VLOOKUP(D10,INDIRECT("'"&$A$1&"'!A:D"),4,FALSE)

Hope this helps!

In article ,
"crazybass2" wrote:

I have a spreadsheet that performs vlookups from several other sheets. From
time to time new sheets are added and I would like to be able to change one
cell and have all the vlookups change to that sheet.

For example,

On sheet1 I have the following vlookups:

A10 =vlookup(D10,'My First Sheet'!A:D,4,false)
A11 =vlookup(D11,'My First Sheet'!A:D,4,false)
A12 =vlookup(D12,'My First Sheet'!A:D,4,false)
and so on...

I would like to have a cell on sheet1 that I can enter the name of the tab I
want to use. In the above case it would be "My First Sheet". If I changed
this cell to "My Second Sheet" I would want the above references lines to
become:

A10 =vlookup(D10,'My Second Sheet'!A:D,4,false)
A11 =vlookup(D11,'My Second Sheet'!A:D,4,false)
A12 =vlookup(D12,'My Second Sheet'!A:D,4,false)
and so on...

I have done this before using VBA, but I would like to do it without coding.

What I've tried is using the following:

A10 =vlookup(D10,"'" & $A$1 & "'!A:D",4,false)
A11 =vlookup(D11,,"'" & $A$1 & "'!A:D",4,false)
A12 =vlookup(D12,,"'" & $A$1 & "'!A:D",4,false)
and so on...

Where A1 would be where I type in a tab name.

This results in an error. Using the "Show Calculation Steps" tool I find
that the range reference in the vlookup still has quotation marks around it.
So instead of evaluating =vlookup(D10,'My Second Sheet'!A:D,4,false) it is
trying to evaluate =vlookup(D10,"'My Second Sheet'!A:D",4,false), which of
course doesn't work. Is there any way to remove the quotation marks, or any
other way of using a cell reference to a tab name in the vlookup function?

All help is much appreciated.

Mike

  #4   Report Post  
crazybass2
 
Posts: n/a
Default

Awesome!

You know, I had looked at the INDIRECT function in help and didn't think it
applied. I guess I should have tried it..

Thanks to both of you for the speedy response.

Mike

"Domenic" wrote:

You can use INDIRECT...

=VLOOKUP(D10,INDIRECT("'"&$A$1&"'!A:D"),4,FALSE)

Hope this helps!

In article ,
"crazybass2" wrote:

I have a spreadsheet that performs vlookups from several other sheets. From
time to time new sheets are added and I would like to be able to change one
cell and have all the vlookups change to that sheet.

For example,

On sheet1 I have the following vlookups:

A10 =vlookup(D10,'My First Sheet'!A:D,4,false)
A11 =vlookup(D11,'My First Sheet'!A:D,4,false)
A12 =vlookup(D12,'My First Sheet'!A:D,4,false)
and so on...

I would like to have a cell on sheet1 that I can enter the name of the tab I
want to use. In the above case it would be "My First Sheet". If I changed
this cell to "My Second Sheet" I would want the above references lines to
become:

A10 =vlookup(D10,'My Second Sheet'!A:D,4,false)
A11 =vlookup(D11,'My Second Sheet'!A:D,4,false)
A12 =vlookup(D12,'My Second Sheet'!A:D,4,false)
and so on...

I have done this before using VBA, but I would like to do it without coding.

What I've tried is using the following:

A10 =vlookup(D10,"'" & $A$1 & "'!A:D",4,false)
A11 =vlookup(D11,,"'" & $A$1 & "'!A:D",4,false)
A12 =vlookup(D12,,"'" & $A$1 & "'!A:D",4,false)
and so on...

Where A1 would be where I type in a tab name.

This results in an error. Using the "Show Calculation Steps" tool I find
that the range reference in the vlookup still has quotation marks around it.
So instead of evaluating =vlookup(D10,'My Second Sheet'!A:D,4,false) it is
trying to evaluate =vlookup(D10,"'My Second Sheet'!A:D",4,false), which of
course doesn't work. Is there any way to remove the quotation marks, or any
other way of using a cell reference to a tab name in the vlookup function?

All help is much appreciated.

Mike


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
Possible Lookup Table Karen Excel Worksheet Functions 5 June 8th 05 10:43 PM
reference sheet tab name in a cell wendyvan Excel Discussion (Misc queries) 1 May 17th 05 04:38 PM
Cell to sheet reference Tom Stout Excel Worksheet Functions 1 January 7th 05 03:58 PM
Automatic cell increment with data from sheet 1 to sheet 2 Big G Excel Worksheet Functions 2 December 20th 04 06:59 PM
VLookup resulting in a blank cell... KempensBoerke Excel Worksheet Functions 1 October 28th 04 10:57 PM


All times are GMT +1. The time now is 06:32 AM.

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

About Us

"It's about Microsoft Excel"