+ Reply to Thread
Results 1 to 21 of 21

VBA code to find and highlight specific text in entire workbook not just active sheet

  1. #1
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    455

    VBA code to find and highlight specific text in entire workbook not just active sheet

    Hi all,

    I'm tring to implement some code which will find and highlight cells which contain "#MULTIVALUE" in any and all tabs within a spreadsheet. The #MULTIVALUE is just plain text and not a formula generated error, if that makes any difference as the report has been pasted special values.
    Last edited by Gti182; 11-15-2010 at 08:41 AM.

  2. #2
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    455

    Re: VBA code to find and highlight

    Found some code i can use but i need to edit it to apply to an entire workbook and not just the active sheet.

    Please Login or Register  to view this content.

  3. #3
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: VBA code to find and highlight in entire workbook not just active sheet

    Please Login or Register  to view this content.
    Last edited by StephenR; 11-15-2010 at 07:53 AM.

  4. #4
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    455

    Re: VBA code to find and highlight specific text in entire workbook not just active s

    That works a treat StephenR.

    Was wondering if it's possible to autofill the searchbox with the "#MULTIVALUE" text instead of having to type it in?

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,299

    Re: VBA code to find and highlight specific text in entire workbook not just active s

    Replace:

    Please Login or Register  to view this content.

    with:

    Please Login or Register  to view this content.

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  6. #6
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: VBA code to find and highlight specific text in entire workbook not just active s

    In practice you're better off searching just the range of actual values rather than the whole sheet.

  7. #7
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    455

    Re: VBA code to find and highlight specific text in entire workbook not just active s

    thanks for the feedback everyone.

    TMShucks i see what you have done there. I still would like to keep the searchbox option for general searches if that is required by the user. I was just wondering if the macro is run, instead of having to manually type in "#MULTIVALUE" if it could already be in the search field before i actually click the search button?

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,299

    Re: VBA code to find and highlight specific text in entire workbook not just active s

    Please Login or Register  to view this content.


    Regards

  9. #9
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    455

    Re: VBA code to find and highlight specific text in entire workbook not just active s

    ah thats brilliant! cheers everybody

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,299

    Re: VBA code to find and highlight specific text in entire workbook not just active s

    You're welcome. Thanks for the feedback.

  11. #11
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: VBA code to find and highlight specific text in entire workbook not just active s

    why not use find replace ?
    you should be able to select all sheets find #MULTIVALUE replace all with #MULTIVALUE and also replace the format
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  12. #12
    Registered User
    Join Date
    01-05-2011
    Location
    Wisconsin, USA
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: VBA code to find and highlight specific text in entire workbook not just active s

    I would like to do something similar to this. I am new to macros and VBA.
    My questions are:
    Is this code entered for a ActiveX command button?
    Do I need an additional box to enter the text to search for? Is this entered in a cell or an ActiveX text box?
    My sheet is Sheet1 and I would like to search column B for the desired text.

    I would like the user to enter a value (in a cell or text box), click the command button and have it find and highlight the desired row.
    Thank you

  13. #13
    Registered User
    Join Date
    08-12-2009
    Location
    Perth, WA
    MS-Off Ver
    Excel 2003
    Posts
    93

    Re: VBA code to find and highlight specific text in entire workbook not just active s

    I'm trying to find and highlight a number of words but for some reason it only finds the last word ie "Bad". Any ideas?

    Please Login or Register  to view this content.

  14. #14
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,299

    Re: VBA code to find and highlight specific text in entire workbook not just active s

    What you have is a list of variable assignments and you are just overwriting the previous value of Fnd with the next, hence you end up with "Bad"

    You probably need to define Fnd as and array and put the entries in the array. You'd then have to loop through the array to check each value.

    You'd maybe have done better to start a new thread and cross refer to this one. As it's marked solved, some people may not notice it ... because I responded to the original thread, I am subscribed to it so see the updates.

    Regards

  15. #15
    Registered User
    Join Date
    06-06-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: VBA code to find and highlight specific text in entire workbook not just active sheet

    I have trying to do this same thing, but instead of highlighting, I want to search for a word, select it, and select everything in the column below it.

    Its for a graph and the data chages columns so I need to search the "Name" in the cells instead of "A1"

    THanks

  16. #16
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,299

    Re: VBA code to find and highlight specific text in entire workbook not just active sheet

    @boarder236: asking a question in someone else's thread is considered hijacking.

    Please start a new thread and, if you feel it is appropriate, insert a link to this thread.

    Regards, TMS

  17. #17
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: VBA code to find and highlight specific text in entire workbook not just active sheet

    Thanks TMS,

    Boarder236,

    Welcome to the Forum, unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  18. #18
    Registered User
    Join Date
    07-17-2012
    Location
    Dubai, UAE
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: VBA code to find and highlight specific text in entire workbook not just active sheet

    Using VBA Code, I want to create a Search button that finds what is written in textbox.1 and I can select the file type from the listbox.1. On top of this, I want all the results to be highlighted once I click the search button. What is the code that I should use? Please help. Thank you.

  19. #19
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: VBA code to find and highlight specific text in entire workbook not just active sheet

    May Badua,

    Welcome to the Forum, unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.

  20. #20
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,299

    Re: VBA code to find and highlight specific text in entire workbook not just active sheet

    @iekika13: you'll need to PM a moderator or administrator. Arlu1201, for example, is an administrator.


    Regards, TMS

  21. #21
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: VBA code to find and highlight specific text in entire workbook not just active sheet

    Thanks TMS.

    Iekika13,

    I have removed your posts.

+ 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