Search across multiple pages, with data from multiple cells printed on separate sheet

benwhite

New member
Joined
Mar 28, 2021
Messages
3
Reaction score
0
Points
0
Excel Version(s)
Excel 365 - Build 2102
Good morning/afternoon all,

Absolute Excel novice here, you all came highly recommended.

I have a spreadsheet containing dishes produced for a catering operation. I would like to have a separate sheet with a search function that can print the name of the dish, and also the title of the location of the dish (Salads, Meat etc).

Some points:

  • I need to be able to add more dishes without amending the search formula used
  • About 45 new data points to be added per day
  • To be used across multiple devices, eg laptop, ipad (not sure if this is impactful)
  • Easy to maintain
  • There is only one column of data per sheet, only the name of the dish is listed
  • If I search for 'corn', the search page will list all the dishes containing 'corn', as well as the title location, eg 'salads', 'hot sides' etc

I have attached my initial working copy, with my idea of how the Search Page could look. Again, absolute novice here so seeking some guru assistance.

Thank you all in advance and apologies if this thread is in the wrong area. Mods, please move if required.

Cheers!

Ben
 

Attachments

  • Dishes.xlsx
    32.7 KB · Views: 7
Here is a VBA solution for you

Code:
Option Explicit


Sub LookUp()
    Application.ScreenUpdating = False
    Dim ws As Worksheet
    Dim s1 As Worksheet
    Set s1 = Sheets("Search")
    Dim lr As Long, lrx As Long
    Dim i As Long, crit As String
    For Each ws In Worksheets
        If ws.Name <> "Search" Then
            lr = s1.Range("B" & Rows.Count).End(xlUp).Row
            crit = s1.Range("B7")
            lrx = ws.Range("B" & Rows.Count).End(xlUp).Row
            For i = 8 To lrx
                If InStr(ws.Range("B" & i), crit) > 0 Then
                    s1.Range("B" & lr + 1) = ws.Range("B" & i)
                    s1.Range("C" & lr + 1) = ws.Name
                End If
            Next i
        End If
    Next ws
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    MsgBox "Completed"


End Sub

Standard Module
How to install your new code
Copy the Excel VBA code
Select the workbook in which you want to store the Excel VBA code
Press Alt+F11 to open the Visual Basic Editor
Choose Insert > Module
Edit > Paste the macro into the module that appeared
Close the VBEditor
Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)


To run the Excel VBA code:
Press Alt-F8 to open the macro list
Select a macro in the list
Click the Run button
 

Attachments

  • Dishes.xlsm
    48.8 KB · Views: 10
Last edited:
Thank you for the swift reply, alansidman!

Followed your instructions, and also used your attached file. I can't seem to generate any results other than 1 result from searching 'corn'. If i search 'chicken', 'beef', 'ranch', no results are returned even though they are contained in the data set. 'Corn' should return 8 results in total from my basic search.

Have I potentially imported the macro incorrectly?
 
The Macro is Case sensitive. So Corn does not equal corn in the lookup. The Macro works for me in the sample file.
 
Fantastic. Thank you again, alansidman!
 
Back
Top