Lookup value across multiple sheets and return sheet name

Tanianiania

Board Regular
Joined
May 3, 2012
Messages
80
Hello

I'm struggling with this one..

I need a formula that reference a value starting in $A4 and looks for it across multiple worksheets and returns the worksheet name

There are 8 worksheets in total, the value will only appear once and won't be duplicated across sheets.

Thankyou
 
Hi Aladin,

Pretty and pretty slick!!!
I took my lookup formula and at the end added &" "& and then your formula and now I get my lookup value AND the sheet name in the same cell.

b1591 Sheet8

What could be better???

Thanks a ton!

Regards,
Howard,[TABLE="width: 48"]
<tbody>[TR]
[TD="class: xl63, width: 64, bgcolor: transparent"][/TD]
[/TR]
</tbody>[/TABLE]

You are welcome.

Very impressed, can't follow what's happening there but it does the job! My Google searches found this question asked many times on forums and nobody gave a direct answer.

Thankyou
Tania

You are welcome. Here how it works:

The COUNTIF bit returns an array of counts, each count corresponding to a sheet. Something like:

{0;1;0}

corresponding to say Sheet1, Sheet2, and Sheet3,

Dividing 1 by this array of values we get:

{#DIV/0!;1;#DIV/0!}

LOOKUP looking at this array picks out the last numeric value (here it's 1) and correlates that positionwise with the sheet set of {"Sheet1";"Sheet2";"Sheet3"} and returns Sheet2 as result.
 
Upvote 0

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Howard,

Can you share th efull formula which returned the sheet name and the cell values?

Thanks

Hi Aladin,

Pretty and pretty slick!!!
I took my lookup formula and at the end added &" "& and then your formula and now I get my lookup value AND the sheet name in the same cell.

b1591 Sheet8

What could be better???

Thanks a ton!

Regards,
Howard,[TABLE="width: 48"]
<tbody>[TR]
[TD="class: xl63, width: 64, bgcolor: transparent"][/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Howard,

Can you share th efull formula which returned the sheet name and the cell values?

Thanks

Something like...

Control+shift+enter, not just enter:
Rich (BB code):

=LOOKUP(9.99999999999999E+307,1/COUNTIF(INDIRECT("'"&SheetList&"'!A2:A100"),$A4),SheetList)
   &" "&VLOOKUP($A2,INDIRECT("'"&INDEX(SheetList,MATCH(TRUE,
      COUNTIF(INDIRECT("'"&SheetList&"'!A2:A10"),A2)>0,0))&"'!A2:C10"),2,0)
 
Upvote 0
Howard,

Can you share th efull formula which returned the sheet name and the cell values?

Thanks

Sure, here it is and its pretty long. Along with all the problems of entering really long formulas into the formula bar.

This formula return includes "The LookUp Value" followed by the verbage "On Sheet -" and then "The Sheet Name" ie.

1234 On Sheet - Sheet3

The VLOOKUP formula:
MySheets is a Named Range of a list of the sheets.
The LookUp value is in B1.
The Look_Up Array is A2:B11 on each sheet.
The Column Index is 2.
The Fourth Argument is 0, an Exact Match.

The sheet name formula:
The LookUp value is in B1.
The Look_Up Array is A2:A11 on each sheet.

Formula is an Array FormulaCtrl + Shift + Enter instead of just Enter.

Howard

=VLOOKUP(B1,INDIRECT("'"&INDEX(MySheets,MATCH(1,--(COUNTIF(INDIRECT("'"&MySheets&"'!A2:A11"),B1)>0),0))&"'!A2:B11"),2,0)& " On Sheet - "
&LOOKUP(9.99999999999999E+307,1/COUNTIF(INDIRECT("'"&MySheets&"'!A2:A11"),B1),MySheets)

Here are the two formulas separate with a "space" joiner with no verbage.

VLOOKUP(B1,INDIRECT("'"&INDEX(MySheets,MATCH(1,--(COUNTIF(INDIRECT("'"&MySheets&"'!A2:A11"),B1)>0),0))&"'!A2:B11"),2,0)

&" "&

LOOKUP(9.99999999999999E+307,1/COUNTIF(INDIRECT("'"&MySheets&"'!A2:A11"),B1),MySheets)
 
Upvote 0
How should we change the formula below if the item that we are looking for can appear in more than one sheet and we just want to return the name of the first sheet on the sheetlist?

Thank you in advance.


You are welcome.



You are welcome. Here how it works:

The COUNTIF bit returns an array of counts, each count corresponding to a sheet. Something like:

{0;1;0}

corresponding to say Sheet1, Sheet2, and Sheet3,

Dividing 1 by this array of values we get:

{#DIV/0!;1;#DIV/0!}

LOOKUP looking at this array picks out the last numeric value (here it's 1) and correlates that positionwise with the sheet set of {"Sheet1";"Sheet2";"Sheet3"} and returns Sheet2 as result.
 
Upvote 0
How should we change the formula below if the item that we are looking for can appear in more than one sheet and we just want to return the name of the first sheet on the sheetlist?

Thank you in advance.

Control+shift+enter, not just enter:

=INDEX(SheetList,MATCH(1,1/COUNTIFS(INDIRECT("'"&SheetList&"'!A2:A100"),$A4),0))

Note. Here is opted for COUNTIFS instead of COUNTIF (for there is no need for the latter on later systems).
 
Upvote 0
Thank you, Aladin! It worked and this was really helpful!
Thank you for your dedication and for sharing your knowledge.
Cheers!
 
Upvote 0
Hi Aladin! Thank you for sharing this it is an incredibly helpful formula!

Is there a way for the formula to work so that the value being looked up (in my case the name of companies) could return the names of multiple sheets that are within the range? (for those where it appears more than once)

Thank you!
 
Upvote 0
Hi Aladin! Thank you for sharing this it is an incredibly helpful formula!

Is there a way for the formula to work so that the value being looked up (in my case the name of companies) could return the names of multiple sheets that are within the range? (for those where it appears more than once)

Thank you!

The array-processing formula you are referring to:
Rich (BB code):
=INDEX(SheetList,MATCH(1,1/COUNTIFS(INDIRECT("'"&SheetList&"'!A2:A100"),$A4),0))
looks up a value that is in A4 and returns a single sheet name from SheetList where a match against A2:A100 is found.

Let A4 house a company name of interest...

In A6 control+shift+enter and copy down:
Rich (BB code):
=IFERROR(INDEX(SheetList,SMALL(IF(ISNUMBER(1/COUNTIFS(INDIRECT("'"&SheetList&"'!A2:A100"),$A$4)),
    ROW(INDIRECT("1:"&COUNTIFS(SheetList,"?*")))),ROWS($A$6:A6))),"")
 
Upvote 0

Forum statistics

Threads
1,224,905
Messages
6,181,663
Members
453,059
Latest member
jkevin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top