+ Reply to Thread
Results 1 to 5 of 5

Cells will not highlight in my defined range

  1. #1
    Forum Contributor
    Join Date
    08-01-2012
    Location
    Tampa
    MS-Off Ver
    Excel 2010
    Posts
    121

    Cells will not highlight in my defined range

    Hello, I am attempting to use the following code to highlight an entire row if a cell in my range is blank. I am not sure why, but it wont highlight. Im assuming its because im not defining a blank cell correctly. Any ideas?

    Please Login or Register  to view this content.
    Thanks!
    Last edited by jayinthe813; 08-27-2012 at 05:27 PM.

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

    Re: Cells will not highlight in my defined range

    Please Login or Register  to view this content.
    Also, you have: Then cell... vs. cell2.
    Ben Van Johnson

  3. #3
    Forum Contributor
    Join Date
    08-01-2012
    Location
    Tampa
    MS-Off Ver
    Excel 2010
    Posts
    121

    Re: Cells will not highlight in my defined range

    Wow, worked great, +rep! May I ask why the logic in the coding I had failed?
    Last edited by Cutter; 08-27-2012 at 07:25 PM. Reason: Removed whole post quote

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

    Re: Cells will not highlight in my defined range

    You coded:
    For Each cell2 in ..., cell2 is the variable which is holding all the data and application info for the cells in the range being tested. However, your If..Then statement uses "cell". This is a different variable from cell2 and is totally empty since you did not use it before; it has to application information or user data information.
    Notice that I put "OPTION EXPLICIT" at the top of my macro. That line forces you to define all of your variables, so when you try to run your macro you'll get an error highlighting "cell" in the IF..Then line because "cell" is undefined.

  5. #5
    Forum Contributor
    Join Date
    08-01-2012
    Location
    Tampa
    MS-Off Ver
    Excel 2010
    Posts
    121

    Re: Cells will not highlight in my defined range

    Right, I see where I made the mistake. Thanks so much for your help!
    Last edited by Cutter; 08-28-2012 at 09:01 AM. Reason: Removed whole post quote

+ 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