+ Reply to Thread
Results 1 to 26 of 26

Macro search entire workbook

  1. #1
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Macro search entire workbook

    Please see attached example

    I have several worksheets with the format mmm yyyy in which I want to search for an account name. Very similar to :
    http://www.excelforum.com/excel-prog...readsheet.html

    I want it to be able to search for a partial hit as well ideally. My macro would be slightly different to the above as I am searching many worksheets, which will be ever growing.
    I need the macro to return the account as well as returning the name of the worksheet tab that it resides in.

    For example if I type "Char" I should get two hits for Charoen so it looks like this

    Account Renewal Month
    Charoen Jan-12search.xls
    Charoen Feb-12

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,252

    Re: Macro search entire workbook

    Hi nick,

    Your pointer to the other answer does an advanced filter of a single list which is much different than a Search.

    Did you know you can search the entire workbook for a string or partial string and click on Find All and it will show what you want?
    Look at http://office.microsoft.com/en-us/ex...001230225.aspx and/or
    http://www.brainbell.com/tutorials/E...d-replace.html
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Re: Macro search entire workbook

    thanks, yes I can see the difference between the filter of a list and a search, but I do need to have a way to display not just the name i am searching for but accompanying information belonging to it in adjacent rows.

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,252

    Re: Macro search entire workbook

    Hi Nick,

    Do a Find and change the options to WORKBOOK and click on FINDALL. Then click on the list of found and see if that isn't good enough for you. It will take you to what it has found. I'm not sure you tried the find all and click on the list yet. It sounds like you want a function that is already in Excel and just don't know how to use it effectively yet.

  5. #5
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Re: Macro search entire workbook

    I am perfectly aware of the Find function but it doesnt replicate what I want to see in a search. It just gives me a list of where my cell ranges are - it doesnt give me any other information that is attributable to the cell in question.

  6. #6
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Macro search entire workbook

    hi nickmax1, please check attachment, hope that helps
    Attached Files Attached Files

  7. #7
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Re: Macro search entire workbook

    watersev,
    thanks a lot but its not quite working.

    I should have deleted the Source colomn as that is complicating matters, but your search macro is finding the right account name but it is putting it in the header "Renewal Month/Year" instead of the "Account" header.
    Under "Renewal Month/Year" I was hoping the macro would return the name of the worksheet the data resides in.

    ?

  8. #8
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Macro search entire workbook

    please check attachment
    Attached Files Attached Files

  9. #9
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Re: Macro search entire workbook

    you sir, are a legend.

    Is the SEARCH button necessary, can the macro be run when something is entered in the search box? no matter if not!

  10. #10
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Macro search entire workbook

    it can but I would stick with this option. If you insist it can be done that way

  11. #11
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Re: Macro search entire workbook

    thats fine...

    I have entered your code into my "master" spreadsheet but now i get an autofilter error??

    Activity test.xlsm

  12. #12
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Macro search entire workbook

    please check attachment

    PS. Search is made on visible sheets only.
    Attached Files Attached Files
    Last edited by watersev; 08-21-2012 at 05:47 AM.

  13. #13
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Re: Macro search entire workbook

    watersev you are some kind of a genius.

    thank you so much. rep added.

  14. #14
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Re: Macro search entire workbook

    Watersev you kindly helped me with a search macro that looked through my workbook....I dont know what has changed but it doesnt work anymore..... It returns the right result but also returns other data???

    Activity test.xlsm

  15. #15
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Macro search entire workbook

    if you change data layout be prepared to amend the code as well
    Attached Files Attached Files

  16. #16
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Re: Macro search entire workbook

    sorry watersev that didnt quite work, still returns random entries (as well as the correct ones)

  17. #17
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168
    I do not get any mistaken data as a result of the search

  18. #18
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Re: Macro search entire workbook

    that is strange....but if select "christ" i get Christchurch and 7 other entries.....

  19. #19
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Macro search entire workbook

    please check attachment, it should be ok now
    Attached Files Attached Files

  20. #20
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Re: Macro search entire workbook

    fantastic!! not sure how you did it but this works - thank you so much

  21. #21
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Re: Macro search entire workbook

    watersev,

    A very small thing, but before the macro is run rows 17 on all sheets (except start, template, brokers, summary) are hidden....after the macro is run it unhides row 17 from the other sheets. Any way we can stop that from happening???

  22. #22
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Macro search entire workbook

    Please Login or Register  to view this content.

  23. #23
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Macro search entire workbook

    please check attachment, press Search button
    Attached Files Attached Files
    Last edited by watersev; 02-01-2013 at 07:16 PM.

  24. #24
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Re: Macro search entire workbook

    i havent gotten round to testing this on my master spreadsheet but based on the test file it is absolutely perfect....thank you so much!!

  25. #25
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Re: Macro search entire workbook

    perfect. Its quite a different code to your original, but however it does it , it does it very very well. thanks again!

  26. #26
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Re: Macro search entire workbook

    Watersev,

    Your code (as always) runs brilliantly. I was wondering if there was any way I can identify the cells in which the results come from and in the next cell to the hyperlink have the output say:

    If the hyperlinked cell is greater than 190 then: "This is an AP/RP"
    Otherwise say "Normal Premium"

    This I would imagine could be done without a macro but i dont know of a formula that can "read" the hyperlink and extract the cell address to come up with that...

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1