+ Reply to Thread
Results 1 to 4 of 4

formatconditions - Erratic Results from simple code

Hybrid View

rkswb formatconditions - Erratic... 07-27-2010, 08:07 PM
shg Re: formatconditions -... 07-27-2010, 08:20 PM
rkswb Re: formatconditions -... 07-28-2010, 07:26 PM
shg Re: formatconditions -... 07-28-2010, 07:45 PM
  1. #1
    Registered User
    Join Date
    07-27-2010
    Location
    Palo Alto, CA
    MS-Off Ver
    Excel 2003
    Posts
    2

    formatconditions - Erratic Results from simple code

    Please help with this issue... it's driving me mad!

    I have a macro that assigns conditional formatting.. yet it assigns random rows for the addresses $H301 and $B301.

    It is sometimes correct, sometimes above or below a few rows (i.e. $B299 or $B304), and sometimes completely out of range (i.e. $B589).

    Regardless of which random row it picks, it's consistent throughout all three conditional format formulas it sets. Please help me find what's wrong. Thank you in advance!!

    With formatrow
                      With .FormatConditions
                        .Delete
                        .Add Type:=xlExpression, Formula1:="=if(len($B301)>0,1,0)"
                        .Add Type:=xlExpression, Formula1:="=if(($H301-14)< today(),1,0)"
                        .Add Type:=xlExpression, Formula1:="=if(($H301-14 - today())<=$J$1,1,0)"
                      End With
                        .FormatConditions(1).Interior.ColorIndex = 35
                        .FormatConditions(2).Interior.ColorIndex = 3
                        .FormatConditions(3).Interior.ColorIndex = 44
     End With
    Last edited by rkswb; 07-28-2010 at 07:26 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: formatconditions - Erratic Results from simple code

    Welcome to the forum.

    Please take a few minutes to read the forum rules, and then edit your post to add CODE tags.

    Thanks.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    07-27-2010
    Location
    Palo Alto, CA
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: formatconditions - Erratic Results from simple code

    Quote Originally Posted by shg View Post
    Welcome to the forum.

    Please take a few minutes to read the forum rules, and then edit your post to add CODE tags.

    Thanks.
    Thanks for the warm welcome. I edited my post with the correct tags, now.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: formatconditions - Erratic Results from simple code

    If you always want it to reference the exact same cells, put $ in front of the row numbers, e.g., $B$301

    If you want it to reference cells in those columns in the row in which the formatting is applied,

        With formatrow.FormatConditions
            .Delete
            .Add Type:=xlExpression, Formula1:="=len(RC2) > 0"
            .Add Type:=xlExpression, Formula1:="=rc8 - 14 < today()"
            .Add Type:=xlExpression, Formula1:="=rc8 - 14 - today() <= r1c10"
            .Item(1).Interior.ColorIndex = 35
            .Item(2).Interior.ColorIndex = 3
            .Item(3).Interior.ColorIndex = 44
        End With
    Last edited by shg; 07-28-2010 at 07:57 PM.

+ 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