+ Reply to Thread
Results 1 to 18 of 18

Highlight entire row based on cell value

  1. #1
    Registered User
    Join Date
    08-12-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    16

    Highlight entire row based on cell value

    From what I understand this is a simple process but since I am new to programming and I am in need of help. I am trying to write into one of my macros that as it is searching in the sheet if it finds CRL in column C and if it finds a value between -1 and 100,000 in column K, then it will highlight the entire row green.What can I do to add this into my macro? Thank you for your help.
    Last edited by clwrs; 08-15-2009 at 03:23 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Simple question

    Hello clwrs,

    Welcome to the Forum!

    Please change your title to reflect your question or problem. A more appropriate title would be "Highlight entire row based on cell value".

    As a new member, please take the time to read over the Forum Rules .
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

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

    Re: Highlight entire row based on cell value

    Can you post up your macro (don't forget to put code tags around the code) and point out IN the macro where you would want this evaluation to occur? There are many ways to do this and how you're working through your sheet will affect the answer(s).
    _________________
    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!)

  4. #4
    Registered User
    Join Date
    08-12-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Highlight entire row based on cell value

    Quote Originally Posted by JBeaucaire View Post
    Can you post up your macro (don't forget to put code tags around the code) and point out IN the macro where you would want this evaluation to occur? There are many ways to do this and how you're working through your sheet will affect the answer(s).
    Please Login or Register  to view this content.
    I want it to come right before end sub or in other words I want it to be the last thing to happen. Also in that same section, I am wondering if it finds CRL in column C it will Italicize the entire row independent of its value. Then if it locates in column K anything less than 25,000 if it will highlight the entire row green. Lastly I want it to search column c and k and if it finds crl and less than 100,000 respectively for the entire row to be highlighted green.

  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: Highlight entire row based on cell value

    It appears the two loops at the end are evaluating the same range. Is the CRL the same first 3 letters?

    If so, you can handle all three loops at once by changing the end to something like this:
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    08-12-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Highlight entire row based on cell value

    Quote Originally Posted by JBeaucaire View Post
    It appears the two loops at the end are evaluating the same range. Is the CRL the same first 3 letters?

    If so, you can handle all three loops at once by changing the end to something like this:
    Please Login or Register  to view this content.
    Well the CRL will be searched for once it ahs been placed in the CCY tab so is it ok to leave it in that loop?

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Highlight entire row based on cell value

    Hello clwrs,

    Thank you for changing your title.

  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: Highlight entire row based on cell value

    Quote Originally Posted by clwrs View Post
    Well the CRL will be searched for once it ahs been placed in the CCY tab so is it ok to leave it in that loop?
    No, if the CRL thing is happening elsewhere, you'll have to take it out. But you can still leave the other two loops merged as shown.

    Maybe something like this to color all the CRL cell/rows from column C all at once, see if you can get this to work:
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    08-12-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Highlight entire row based on cell value

    Quote Originally Posted by JBeaucaire View Post
    No, if the CRL thing is happening elsewhere, you'll have to take it out. But you can still leave the other two loops merged as shown.

    Maybe something like this to color all the CRL cell/rows from column C all at once, see if you can get this to work:
    Please Login or Register  to view this content.
    It says that there is a compile error: Named argument not found - This appears and highlights what I have marked in Red. What should I do from here? Also how do I instead of highlighting CRL, Italicize CRL? Then after Italicizing I want it to search for all CRLs that are less than 100,000 in column K and by doing so highlight that row in green.

  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: Highlight entire row based on cell value

    That should be Criteria1:=, sorry, forgot the 1.

    Well, I forgot about that column K stuff. We'll have to build a loop and check them all.

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    08-12-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Highlight entire row based on cell value

    Quote Originally Posted by JBeaucaire View Post
    That should be Criteria1:=, sorry, forgot the 1.

    Well, I forgot about that column K stuff. We'll have to build a loop and check them all.

    Please Login or Register  to view this content.
    Ok, I ran it and it only highlighted the column headers rather than highlighting those rows where it found CRL. What should I tweak?

  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: Highlight entire row based on cell value

    Post up a sample worksheet this portion of the code is trying to run on.

  13. #13
    Registered User
    Join Date
    08-12-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Highlight entire row based on cell value

    Thanks for all of your help thus far. I have been able to accomplish everyting minus highlighting the entire row green if the value in column k is less than or equal to 25000 but greater than 0. Do you know how I could do this in VBA or even using the conditional formatting option in excel 2007?

  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: Highlight entire row based on cell value

    The code I provided should highlight the rows green, it did in my tests. I don't have 2007 so you'll have to press F1 in Excel and read up on CF in Excel 2007.

  15. #15
    Registered User
    Join Date
    08-12-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Highlight entire row based on cell value

    Quote Originally Posted by JBeaucaire View Post
    The code I provided should highlight the rows green, it did in my tests. I don't have 2007 so you'll have to press F1 in Excel and read up on CF in Excel 2007.

    It is telling me that: "Out of memory" and the it highlights: If Cells.Value Like "*CRL*" Then

    What might be causing this? Also how would I go back into the first tab, position, and delete all the rows that have just been cut?

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

    Re: Highlight entire row based on cell value

    Ouch, my bad. ONE little letter made the script run out of control. Take that "s" off:
    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    08-12-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Highlight entire row based on cell value

    Quote Originally Posted by JBeaucaire View Post
    Ouch, my bad. ONE little letter made the script run out of control. Take that "s" off:
    Please Login or Register  to view this content.

    Thanks, that was great.

    Do you remember the sorting function that you did for me? Well now I am trying to do another one after adding more data. I tried to just reinsert your code further down the macro but when I do it (after I have changed the 995 and 9FF to AM and CL and also changed the end location to the correct tabs the "Select Case Left(cell.Value, 2) is highlighted and said it is a Type mismatch. What shoudl I do to change this so that it will cut adn paste? Also is there a way to include in this code a way to delete all blank rows so that those leftover will all move to the top? Thanks again for your help

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

    Re: Highlight entire row based on cell value

    Start a new thread with all the pertinent code/sample sheets/links to other threads and we'll deal with it there.

    Meanwhile, if that takes care of this need, be sure to EDIT your original post, click Go Advanced and mark the PREFIX box [SOLVED].


    (Also, use the blue "scales" icon in our posts to leave Reputation Feedback, it is appreciated)

+ 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