Find what tab Value is on.

charlee63

Board Regular
Joined
Jan 7, 2010
Messages
147
I am trying to find what tab a value is on. The below is Named SheetList
Breads
Breakfast
Cakes
Cookies
Ingredients
Pastries & Sweets
Pies
Rolls
=LEFT(VLOOKUP($A2,INDIRECT("'"&INDEX(SheetList,MATCH(1,--(COUNTIF(INDIRECT("'"&SheetList&"'!$A$1:$A$1000"),$A2)>0),0))&"'!$A$1:$d$1000"),4,FALSE),FIND(" - ",VLOOKUP($A2,INDIRECT("'"&INDEX(SheetList,MATCH(1,--(COUNTIF(INDIRECT("'"&SheetList&"'!$A$1:$A$1000"),$A2)>0),0))&"'!$A$1:$d$1000"),4,FALSE),1)-1)
with Ctrl-Shift-Enter
1738242443601.png

The above formula is in Tab column. But it is given the wrong tab name. It is on the Bread tab not the Breakfast tab.
Can anyone see what the issue is or give me a different way to get info?
Using Excel 13.
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
As for the Or part of your question, maybe just use Ctrl+F and use the option to search the whole workbook as well as Find All option? You might discover that you have the value in more than one sheet.
 
Upvote 0
The following is a VBA approach.

The macro presents an InputBox where the user inputs the term to be searched. When the term is located (could be on multiple sheets),
The sheet name and cell location is presented in a listbox on a userform. The same information is also printed to a sheet named "Location".

VBA Code:
Option Explicit

Sub SearchAllSheetsAndDisplayResults()
    Dim ws As Worksheet
    Dim searchTerm As String
    Dim foundRange As Range
    Dim firstAddress As String
    Dim results As Collection
    Dim resultText As Variant
    Dim resultsSheet As Worksheet

    searchTerm = InputBox("Enter the term to search for:")
    
    ' Create a new worksheet for results
    On Error Resume Next
    Application.DisplayAlerts = False
    Set resultsSheet = Worksheets("Locations")
    If Not resultsSheet Is Nothing Then resultsSheet.Delete
    Application.DisplayAlerts = True
    On Error GoTo 0
    Set resultsSheet = Worksheets.Add
    resultsSheet.Name = "Locations"
    
    ' Create a collection to store results
    Set results = New Collection
    
    For Each ws In ThisWorkbook.Worksheets
        Set foundRange = ws.Cells.Find(What:=searchTerm, LookIn:=xlValues, LookAt:=xlPart, _
                                       SearchOrder:=xlByRows, SearchDirection:=xlNext, _
                                       MatchCase:=False)
        If Not foundRange Is Nothing Then
            firstAddress = foundRange.Address
            Do
                resultText = "Sheet: " & ws.Name & " Cell: " & foundRange.Address
                results.Add resultText
                
                ' Paste results into "Locations" sheet
                resultsSheet.Cells(results.Count, 1).Value = ws.Name
                resultsSheet.Cells(results.Count, 2).Value = foundRange.Address
                resultsSheet.Cells(results.Count, 3).Value = foundRange.Value
                
                Set foundRange = ws.Cells.FindNext(foundRange)
            Loop While Not foundRange Is Nothing And foundRange.Address <> firstAddress
        End If
    Next ws
    
    ' Show UserForm with results
    With UserForm1
        .ListBox1.Clear
        For Each resultText In results
            .ListBox1.AddItem resultText
        Next resultText
        .Show
    End With
End Sub

Paste this code in the userform :

Code:
Private Sub CommandButton1_Click()
    Unload Me
End Sub

Create the UserForm1 ... paste a Listbox and a command button on the form.

Paste a command button on your worksheet and connect it to the main macro
"SearchAllSheetsAndDisplayResults"
 
Upvote 0

Forum statistics

Threads
1,226,117
Messages
6,189,061
Members
453,524
Latest member
AshJames

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