Results 1 to 7 of 7

Macro failing at conditional formatting font colour

Threaded View

  1. #1
    Registered User
    Join Date
    11-04-2013
    Location
    UK
    MS-Off Ver
    2016 (Office 365 Business Premium)
    Posts
    7

    Post Macro failing at conditional formatting font colour

    Hi there,

    I've recorded a macro in Excel 2007 which opens a file then highlights columns I to CH, then applies conditional formatting so that if a cell has a value of <0, it applies a red font with pink fill colour. Here's the code:

    Formula: copy to clipboard
    Sub highlight()
    '
    ' highlight Macro
    '

    '
    ChDir "S:\Reports"
    Workbooks.Open Filename:="S:\Reports\78weeks.xls"
    Columns("I:I").Select
    ActiveWindow.ScrollColumn = 8
    ActiveWindow.ScrollColumn = 9
    ActiveWindow.ScrollColumn = 12
    ActiveWindow.ScrollColumn = 15
    ActiveWindow.ScrollColumn = 27
    ActiveWindow.ScrollColumn = 29
    ActiveWindow.ScrollColumn = 37
    ActiveWindow.ScrollColumn = 40
    ActiveWindow.ScrollColumn = 50
    ActiveWindow.ScrollColumn = 54
    ActiveWindow.ScrollColumn = 59
    ActiveWindow.ScrollColumn = 60
    ActiveWindow.ScrollColumn = 62
    Columns("I:CH").Select
    Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
    Formula1:="=0"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Font
    .Color = -16383844
    .TintAndShade = 0
    End With
    With Selection.FormatConditions(1).Interior
    .PatternColorIndex = xlAutomatic
    .Color = 13551615
    .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False
    Range("A1:A2").Select
    ActiveWorkbook.Save
    ActiveWindow.Close
    End Sub


    The problem is, when I run it, it fails and hitting debug takes me to the below lines, highlighted.

    Formula: copy to clipboard
    With Selection.FormatConditions(1).Font
    .Color = -16383844


    If anyone could point me in the right direction it would be greatly appreciated.
    Last edited by RC-AMG; 01-12-2015 at 12:28 PM. Reason: Solved.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Conditional colour formatting without seeing the font used for the condition.
    By kristyhutt in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-18-2013, 01:07 AM
  2. Replies: 1
    Last Post: 09-12-2013, 02:09 PM
  3. Replies: 15
    Last Post: 05-31-2012, 10:34 AM
  4. Replies: 2
    Last Post: 10-03-2009, 05:01 PM
  5. Replies: 9
    Last Post: 10-22-2007, 07:29 AM

Tags for this Thread

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