+ Reply to Thread
Results 1 to 2 of 2

Need help looping through multiple sheets to conditionally format the same range/sheet

Hybrid View

  1. #1
    Registered User
    Join Date
    08-24-2012
    Location
    Columbus
    MS-Off Ver
    Excel 2010
    Posts
    46

    Need help looping through multiple sheets to conditionally format the same range/sheet

    Below is my current code for the particualr range I'm having an issue with. The highlighted line is the first issue I run into and I think it might have something to do with a section of code prior to that line in the code below. If I "select" this range it will work fine but I'm trying to avoid doing that to loop through each sheet.

    'SECTOR
        'LESS THAN
            .Range("N9:N1200,O7").FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, Formula1:="=0"
            With .Range("N9:N1200,O7").FormatConditions(1).Font
                .Bold = True
                .Color = -16777024
            End With
            With .Range("N9:N1200,O7").FormatConditions(1).Interior
                .PatternColorIndex = xlAutomatic
                .ThemeColor = xlThemeColorAccent2
                .TintAndShade = 0.799981688894314
            End With
            .Range("N9:N1200,O7").FormatConditions(1).StopIfTrue = False
        'GREATER THAN
            .Range("N9:N1200,O7").FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, Formula1:="=0"
            With .Range("N9:N1200,O7").FormatConditions(2).Font
                .Bold = True
                .Color = -11489280
            End With
            With .Range("N9:N1200,O7").FormatConditions(2).Interior
                .PatternColorIndex = xlAutomatic
                .Color = 13365426
            End With
            .Range("N9:N1200,O7").FormatConditions(2).StopIfTrue = False
        'INSERTING ARROWS
            .Range("N9:N1200,O7").FormatConditions.AddIconSetCondition
            With .Range("N9:N1200,O7").FormatConditions(1)
                .IconSet = ActiveWorkbook.IconSets(xl3Arrows)
            End With
            .Range("N9:N1200,O7").FormatConditions(1).IconCriteria(1).Icon = xlIconRedDownArrow
            With .Range("N9:N1200,O7").FormatConditions(1).IconCriteria(2)
                .Type = xlConditionValueNumber
                .Value = 0
                .Operator = 7
            End With
            With .Range("N9:N1200,O7").FormatConditions(1).IconCriteria(3)
                .Type = xlConditionValueNumber
                .Value = 0
                .Operator = 7
                .Icon = xlIconGreenUpArrow
            End With

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,028

    Re: Need help looping through multiple sheets to conditionally format the same range/sheet

    In my experience, you will need to select both the sheet and the range where you want to add the CF, much as you would in "real life".

    I generally define a worksheet variable and set it to the Active Sheet. Then, when you've finished your loop you can restore the original sheet. Use ScreenUpdating = False.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Best Way to Conditionally Format Range (Multiple Columns and Rows)?
    By freybe06 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-14-2013, 04:53 PM
  2. [SOLVED] Looping through sheets to clear a specified range, but excluding some sheets
    By d.sanchez in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-03-2013, 02:39 PM
  3. [SOLVED] Copy range from multiple sheets, into a master sheet and moving over by variable col range
    By g1eagle in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-23-2012, 01:36 PM
  4. [SOLVED] Multiple Sheets be reflected in 1 sheets as a summary (looping)
    By Kooper in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-21-2012, 03:21 AM
  5. Replies: 4
    Last Post: 06-04-2012, 12:08 PM

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