Results 1 to 20 of 33

Thread: Delete all conditional formatting and coloring conditional on specific rows

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #8
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,894
    Location
    but I'm afraid you misunderstood me.
    Most likely


    Now, the last table I sent and the addition in the columns P , Q , R - was only if you need in the calculation and tests to compare them.
    OPQR cols implied that each row might have different thresh holds


    I'm not that good at writing macros, but I have a feeling that you always take the values that are in/from O4:R4, and maybe I don't understand the macro and it takes its values from each row adjacent to it (so must be).
    Yes, not required but easier since otherwise the 4 thresh holds would have to be passed to the sub. That was my first approach but I decided that it was not very elegant. I can put it back if it's a problem



    I can't figure out where you get that 4,5,6,7,8,9 and 17.
    The subroutine definition might give you a hint since I like to give variables meaningful names

    Private Sub AddCF(rowNum As Long)
        Dim T1 As Long, T2 As Long, T3 As Long, T4 As Long
        Dim CFormula As String
        Dim R As Range
        
        Set R = ActiveSheet.Rows(rowNum)

    In the last file you sent me, I decided to try and test by plotting numbers on row 21 and when I hit the macro, nothing like coloring came out on that row.
    I didn't spend time doing every row, I only did some that had a value in OPQR, I just didn't include row 21

           Call AddCF(15)
           Call AddCF(17)
           Call AddCF(21)

    It's easy enough to have the macro do all rows, keying off of OPRQ values (skip rows where the col O is blank


    Sub DoAllRows()
        Dim r As Long
        
        With ActiveSheet
            With .Range("C3:N60")
                .FormatConditions.Delete
            
                .Interior.ColorIndex = xlColorIndexNone
            
                'clear any empty, but text i.e. 0 length strings
                Call .Replace(vbNullString, "###ZZZ###", LookAt:=xlWhole)
                Call .Replace("###ZZZ###", vbNullString, LookAt:=xlWhole)
            
                'clear the settings
                .Find What:=vbNullString, After:=.Cells(1, 1), LookIn:=xlFormulas, LookAt:=xlPart, _
                       SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False
                .Replace What:=vbNullString, Replacement:=vbNullString, ReplaceFormat:=False
            End With
            
            For r = 3 To 60
                Call AddCF(r)
            Next r
        End With
    End Sub
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •