+ Reply to Thread
Results 1 to 2 of 2

Conditional formatting macro

Hybrid View

  1. #1
    Registered User
    Join Date
    10-26-2011
    Location
    York
    MS-Off Ver
    Excel 2007
    Posts
    7

    Conditional formatting macro

    This is an awkward one, which I've found a solution for but it's not very efficient so I'm hoping to find a better one. I have a spreadsheet which is automatically generated by another program. I want to conditionally format the cells within it but some columns have different conditions. There is a pattern, however, 3-5, 8-10, 13-15 etc., need one and 6-7, 11-12, 16-17 etc., need another. This is what I have come up with but it takes too long:-

    Sub condformat1()
    Columns("c:e").Select
    Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, _
    Formula1:="=100"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Font
    .Color = -16752384
    .TintAndShade = 0
    End With
    With Selection.FormatConditions(1).Interior
    .PatternColorIndex = xlAutomatic
    .Color = 13561798
    .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False
    Columns("h:j").Select
    Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, _
    Formula1:="=100"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Font
    .Color = -16752384
    .TintAndShade = 0
    End With
    With Selection.FormatConditions(1).Interior
    .PatternColorIndex = xlAutomatic
    .Color = 13561798
    .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False
    Columns("m:o").Select
    Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, _
    Formula1:="=100"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Font
    .Color = -16752384
    .TintAndShade = 0
    End With




    Is there a better way to do this?

  2. #2
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Conditional formatting macro

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

+ 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