+ Reply to Thread
Results 1 to 18 of 18

How to search for a word in a column and have entire row opaque once word is found

  1. #1
    Registered User
    Join Date
    08-31-2009
    Location
    washington, dc
    MS-Off Ver
    Excel 2003
    Posts
    55

    How to search for a word in a column and have entire row opaque once word is found

    Hello,

    I need my macros to search for the word "Cancel" or "Cancelled" in columns "T" and "U". Once found, I need the macros to make that entire row an opaque shading.

    There will be other wording in these cells that contain "Cancel" or "Cancelled". Is it possible for the macros to search in the sentence and find the words "Cancel" or "Cancelled"

    I started on the code below but am stuck.

    Please Login or Register  to view this content.

    Any ideas? Thank you for your help!

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to search for a word in a column and have entire row opaque once word is foun

    Hehe, "opaque" is a great word. Now, what color did you have in mind?
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    08-31-2009
    Location
    washington, dc
    MS-Off Ver
    Excel 2003
    Posts
    55

    Re: How to search for a word in a column and have entire row opaque once word is foun

    I need the pattern style to be opaque. In the "fill" tab in the format cells command, there are different pattern styles you can choose from. I just need one that is opaque and can still see the words underneath.

  4. #4
    Registered User
    Join Date
    08-31-2009
    Location
    washington, dc
    MS-Off Ver
    Excel 2003
    Posts
    55

    Re: How to search for a word in a column and have entire row opaque once word is foun

    Sorry. maybe "opaque" wasn't the correct word. lol

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to search for a word in a column and have entire row opaque once word is foun

    With no sample sheet, it's hard to know the best way to advise you.

    Can you simply turn on the Data > Filter > Autofilter and custom filter column B by "contains cancel" ?

    Then you could simply color the visible rows and turn the AutoFilter back off. That could be put into a simple macro, too.

  6. #6
    Registered User
    Join Date
    08-31-2009
    Location
    washington, dc
    MS-Off Ver
    Excel 2003
    Posts
    55

    Re: How to search for a word in a column and have entire row opaque once word is foun

    The sheet has thousands of lines of information, 17 tabs, and it has to be ran twice, maybe three times a week.

    I'd like to put it in a macro if at all possible. Wondering how i could go about doing it.

  7. #7
    Registered User
    Join Date
    08-31-2009
    Location
    washington, dc
    MS-Off Ver
    Excel 2003
    Posts
    55

    Re: How to search for a word in a column and have entire row opaque once word is foun

    I just recorded a macro....for the type of pattern needed:

    Please Login or Register  to view this content.
    Now i just need to combine this with a find "Cancelled" or "Cancel" In columns T and U
    Last edited by NBVC; 09-03-2009 at 10:50 AM.

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to search for a word in a column and have entire row opaque once word is foun

    First, does the Autofilter approach work? If at least one column in your dataset is filled compeltely all the way down, no gaps, then you can autofilter column B by "contains cancel".

    If that works, it will make for a very short macro.

    A sample sheet always makes this easier.

  9. #9
    Registered User
    Join Date
    08-31-2009
    Location
    washington, dc
    MS-Off Ver
    Excel 2003
    Posts
    55

    Re: How to search for a word in a column and have entire row opaque once word is foun

    hmmm...i tried to upload an example file but it didn't work.

  10. #10
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to search for a word in a column and have entire row opaque once word is foun

    If it's too big, zip it first.

    GO ADVANCED > paperclip > browse > UPLOAD > submit

  11. #11
    Registered User
    Join Date
    08-31-2009
    Location
    washington, dc
    MS-Off Ver
    Excel 2003
    Posts
    55

    Re: How to search for a word in a column and have entire row opaque once word is foun

    Is there a formula that could search for those two words in a sentence in those columns?

  12. #12
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to search for a word in a column and have entire row opaque once word is foun

    Duh, we're talking about formatting a row based on a cell value. Duh. Can't believe I got tunnel vision on the macro thing.

    This is conditional formatting. You can set a conditional formatting rule for the row that changes the color if cell B contains the work "cancel".

    In this sample attached file, I just used a conditional format formula of:
    =ISNUMBER(SEARCH("cancel",$B1))
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    08-31-2009
    Location
    washington, dc
    MS-Off Ver
    Excel 2003
    Posts
    55

    Re: How to search for a word in a column and have entire row opaque once word is foun

    Thanks for your help!

    I seem to only be able to change the pattern just in the cell, instead of the row.

    Any suggestions?

  14. #14
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to search for a word in a column and have entire row opaque once word is foun

    Highlight the entire Range of rows. Make sure they are ALL highlighted. Then set the CF based on the primary row you have highlighted.

    In my example, I highlighted a bunch or columns from primary row1 down to 10 or so. Then the formula I used had $B1 in it so it locks the column with the absolute $B but uses a relative 1 allowing the formula to change itself as it goes down the rows I have highlighted.

    Another way is to get row 1 working. Then use the Format Painter icon to apply that rows formatting to other rows.

  15. #15
    Registered User
    Join Date
    08-31-2009
    Location
    washington, dc
    MS-Off Ver
    Excel 2003
    Posts
    55

    Re: How to search for a word in a column and have entire row opaque once word is foun

    Hey,

    I want to say thanks again for all of your help. Everything has been really easy for me to understand after your explanation.

    For some reason, when i put in the conditional formatting formula for "cancel", it still will not recognize it.

    It will recognize it if i put in "Format only cells that contain:", but then it will only recognize the individual cell and not the row. I tried the absolute "$" approach but still no luck.

    I will keep trying it out. Hopefully something will turn out.

  16. #16
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,609

    Re: How to search for a word in a column and have entire row opaque once word is foun

    Please post the formula you used in the Conditional Formatting dialog.
    Ben Van Johnson

  17. #17
    Registered User
    Join Date
    08-31-2009
    Location
    washington, dc
    MS-Off Ver
    Excel 2003
    Posts
    55

    Re: How to search for a word in a column and have entire row opaque once word is foun

    =ISNUMBER(SEARCH("cancel",$T1))

    I need it to search for the word "cancel" in column "T". Once it spots it, I need it to highlight the entire row.

    The word "cancel" may be in a sentence as well. I still need it recognized.

  18. #18
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,609

    Re: How to search for a word in a column and have entire row opaque once word is foun

    The formula works:
    CF(test).xls

+ 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