Consulting

Results 1 to 4 of 4

Thread: Trouble with code to grab data from multiple sheets and filter and list

  1. #1

    Question Trouble with code to grab data from multiple sheets and filter and list

    Hi there.
    I am trying to set up a search function for my Workbook so that I can search data from every page in the workbook and then display the results on the original page (under the search bar.) I am working from an example and it works fine if all my data is on the page with the search feature. But, I can't figure out how to change the code so that it will search every page. I think the answer is in the code where it loads the sheet into a variable : Set sht = ActiveSheet
    Can anyone help with what I would need to change to get it to load/search ALL sheets?
    Thanks in advance!


    RD Index M.xlsm

  2. #2
    Excel 2003 by the way!

  3. #3
    VBAX Regular Kevin#'s Avatar
    Joined
    Dec 2015
    Location
    Conwy (North Wales)
    Posts
    26
    Location
    There are no macros visible in the attached file, presumably stored elsewhere.

    You need to loop your "Search Codes" through all sheets in turn, adding results from successive sheets below your current results
    something like:
    For j = 1 To to Sheets.Count
    
    'INSERT your "SearchCode" HERE , ensuring search ranges refer to sheet(j) 
    
    Sheets(j).Range("A:F")  'example
                
    Next j
    OR
    For j = 1 To to Sheets.Count
    'wrap code in With statement and use .range notation
    With sheets(j)
    'INSERT your "SearchCode" HERE, ensuring search ranges refer to sheet(j) 
    .Range("A:F") 'example 
     End With          
    Next j

  4. #4
    Thanks, I'll work with that!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •