+ Reply to Thread
Results 1 to 9 of 9

Formula for color coding

  1. #1
    Registered User
    Join Date
    03-05-2007
    Posts
    39

    Formula for color coding

    I want to highlight a row if column N is >1.00 and also if it is <0. I want to color it dull oranage ColorIndex = 40 and Pattern = xlSolid.

    Is there a way.

  2. #2
    Forum Contributor
    Join Date
    04-24-2007
    Location
    NYC
    MS-Off Ver
    2k3/2k7/2010
    Posts
    270
    Try this macro. This is assuming the maximum rows to check for is static, i currently set it to 200. You can change it to any number you want. It will check the first two hundreds rows of Column N
    sub col_N_check()
    for i = 1 to 200
    if ActiveSheet.Range("N"&i).Value > 1 and ActiveSheet.Range("N"&i).Value < 0 Then
    ActiveSheet.Range("N"&i).Interior.ColorIndex = 40
    ActiveSheet.Range("N"&i).Interior.Pattern = "xlSolid"
    end if
    next i
    end sub

  3. #3
    Registered User
    Join Date
    03-05-2007
    Posts
    39
    nothings happening. I don't get an error; I just see any results.

  4. #4
    Forum Contributor
    Join Date
    04-24-2007
    Location
    NYC
    MS-Off Ver
    2k3/2k7/2010
    Posts
    270
    Quote Originally Posted by slx
    Try this macro. This is assuming the maximum rows to check for is static, i currently set it to 200. You can change it to any number you want. It will check the first two hundreds rows of Column N

    Opps use OR instead of And
    and remove the quotations from "xlSolid"

  5. #5
    Registered User
    Join Date
    03-05-2007
    Posts
    39
    That worked alittle. What it did was highlight that cell and only the ones greater than 1. It did nothing to the 0's.

  6. #6
    Forum Contributor
    Join Date
    04-24-2007
    Location
    NYC
    MS-Off Ver
    2k3/2k7/2010
    Posts
    270
    Ur first msg said anything < 0, that would mean negative numbers. If you want to include 0, then you change it to = 0

  7. #7
    Registered User
    Join Date
    03-05-2007
    Posts
    39
    Okay that worked. But how do I get it to hightlight the whole row. It is just highlighting the cell in column N.

  8. #8
    Forum Contributor
    Join Date
    04-24-2007
    Location
    NYC
    MS-Off Ver
    2k3/2k7/2010
    Posts
    270
    This should make it select the row instead of the cell.
    sub col_N_check()
    dim curr_Row as string
    for i = 1 to 200
    if ActiveSheet.Range("N"&i).Value > 1 or ActiveSheet.Range("N"&i).Value = 0 Then
    curr_Row = i & ":" & i
    ActiveSheet.Range(curr_Row).Interior.ColorIndex = 40
    ActiveSheet.Range(curr_Row).Interior.Pattern = "xlSolid"
    end if
    next i
    end sub

  9. #9
    Registered User
    Join Date
    03-05-2007
    Posts
    39
    Yea!!! It works wonderful. Thank you so much. That saves me about 5 minutes everyday.

    Thank you.

+ 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