+ Reply to Thread
Results 1 to 3 of 3

Color set of rows according to sort.

Hybrid View

  1. #1
    Registered User
    Join Date
    07-02-2008
    Location
    Sweden
    Posts
    3

    Color set of rows according to sort.

    So, I have this sheet and VBA code.

    Code look like this:

    Sub Macro()
    '
    ' B3 Macro
    ' Macro V.1
    '
    
    '
    '---------------------------------------Find Last Row With Data-----------------------------------
    Sheets("Sheet1").Select
    
    Dim LastRow As Long
        If WorksheetFunction.CountA(Cells) > 0 Then
        LastRow = Cells.Find(What:="*", After:=[A1], _
        SearchOrder:=xlByRows, _
        SearchDirection:=xlPrevious).Row
        End If
    '---------------------------------------Delete And Keep Relevant Columns-------------------------
        Range("A:A,C:C,E:F,H:I,K:U,W:BQ").Select
        Range("A1").Activate
        Selection.Delete Shift:=xlToLeft
    '---------------------------------------Get NPC Date---------------------------------------------
        Range("F2").Select
        ActiveCell.FormulaR1C1 = "=MID(R[-1]C[-1],12,11)"
        Range("F2").Select
        ActiveCell.FormulaR1C1 = "=MID(RC[-1],12,11)"
        Range("F2").Select
        Selection.AutoFill Destination:=Range("F2:F" & LastRow), Type:=xlFillDefault
        Range("F2:F" & LastRow).Select
        Columns("F:F").EntireColumn.AutoFit
    '---------------------------------------Filter After A3,B3 Status------------------------------------
        Range("A1").Select
        Selection.AutoFilter
        Selection.AutoFilter Field:=2, Criteria1:="A3,B3"
    '---------------------------------------Sort After Route/Date--------------------------------------
        Range("A1").Select
        Range("A2").Sort Key1:=Range("C2"), Order1:=xlAscending, Key2:=Range _
        ("F2"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase _
        :=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _
        DataOption2:=xlSortNormal
    
    End Sub
    You can see what this VBA will do. I want to be able to color ever second SET of rows that match according to column F. Every second time the value in the F column change I want to color it. How to do it?

    See example:

    A B C D E F
    1 2 3 4 5 6
    1 2 3 4 5 6

    7 8 9 0 1 2
    7 8 9 0 1 2
    3 4 5 6 7 8
    3 4 5 6 7 8
    3 4 5 6 7 8

    9 0 1 2 3 4
    9 0 1 2 3 4

  2. #2
    Registered User
    Join Date
    07-02-2008
    Location
    Sweden
    Posts
    3
    Ill try to explain in psedu-code.

    IF cell above =< then SET selected color red

  3. #3
    Registered User
    Join Date
    07-02-2008
    Location
    Sweden
    Posts
    3

    This is...

    what I would like to do, bit I cant get it to work.

    http://www.dailydoseofexcel.com/arch...color-banding/

+ 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