+ Reply to Thread
Results 1 to 6 of 6

Macro Not Working for Search in Multiple Columns

  1. #1
    Registered User
    Join Date
    12-13-2012
    Location
    Minnesota
    MS-Off Ver
    Excel 2010
    Posts
    40

    Question Macro Not Working for Search in Multiple Columns

    I have this macro that seems to have a quirk where it is not looking through all the columns that are selected. This is looking for keywords and changing the font to bold red type for just those keywords in a cell. It works but am now seeing that it is not looking through all the columns selected in the range. Any thoughts of what you see could be the problem is greatly appreciated.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Macro Not Working for Search in Multiple Columns

    vcs1161,

    Here is an overhauled version of your code, with comments. Give it a try:
    Please Login or Register  to view this content.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    12-13-2012
    Location
    Minnesota
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Macro Not Working for Search in Multiple Columns

    I am getting this error message on the last line "Erase arrTerms"

    Error 1004 "Unable to get the Text Property of the Range Class"

  4. #4
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Macro Not Working for Search in Multiple Columns

    Did you alter the code? arrTerms() should be dimmed as String, not Range

  5. #5
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Macro Not Working for Search in Multiple Columns

    Alternately, if you could upload a sample workbook that is experiencing the error, I can take a look at it, because I have been unable to duplicate that error.

  6. #6
    Registered User
    Join Date
    12-13-2012
    Location
    Minnesota
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Macro Not Working for Search in Multiple Columns

    I did not alter the code but it seems to do this and hang when I select a range of columns. But it does work when I select a range of specific cells. There will be times when selecting the column will be more efficient since there can be some very large worksheets. The other thing I noticed is that sometimes it will not find the part of a string after the second, third, etc. times. For instance, I ran this again after my first successful run was complete and ran another search for "wed" but it did not find that in Wednesday (column A). And yet it was found after I reset the font and ran it in the first pass/attempt.

    I attached a file that I am testing this on.

    TestingMacroSearch.xlsx

+ 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