Color Rows by Month
So, I have a group that ssits down every month and schedules who is gong to work each activity. The spreadsheet was getting hard to follow across a row so I adapted an existing macro to color-code by month.
Option Explicit
Sub ColorMonthlys()
Dim Ranger As String
Dim LastCol As Long, lastRow As Long, ColorNum As Long
Dim FirstCol As Long
Dim SortRanger As Variant
Dim C As Long
Dim H As Long
Dim Quo As String
Dim MonNm As Variant, RGBnm As Variant
Quo = Chr(34)
Application.ScreenUpdating = True
Sheets("Schedules").Activate
ActiveSheet.Unprotect
lastRow = Range("a99999").End(xlUp).Row
LastCol = 9 'I
Range(Cells(2, 1), Cells(lastRow, LastCol)).Select
Selection.Interior.ColorIndex = False
Cells(2, 1).Select
FirstCol = 1
MonNm = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
RGBnm = Array(RGB(153, 204, 255), _
RGB(131, 241, 123), _
RGB(255, 153, 255), _
RGB(255, 255, 0), _
RGB(250, 191, 143), _
RGB(205, 216, 176), _
RGB(204, 255, 204), RGB(102, 204, 255), _
RGB(255, 204, 153), RGB(157, 187, 255), _
RGB(207, 183, 255), RGB(93, 174, 255))
Debug.Print "uColor: " & UBound(RGBnm) & " uMonth: " & UBound(MonNm)
For H = 0 To UBound(MonNm)
SortRanger = RGBnm(H)
For C = 2 To lastRow
Application.StatusBar = MonNm(H)
If Month(Cells(C, FirstCol)) = MonNm(H) Then
If C Mod 2 = 0 Then
Sheets("schedules").Range(Cells(C, 1), Cells(C, LastCol)) _
.Interior.Color = SortRanger
Else
Sheets("schedules").Range(Cells(C, 1), Cells(C, LastCol)) _
.Interior.ColorIndex = False
End If
End If
Next C
Next H
Application.StatusBar = False
lastRow = Range("B99999").End(xlUp).Row
Cells(lastRow, 1).Select
ActiveSheet.Protect
MonNm = 0
RGBnm = 0
C = 0
MsgBox "Updated Schedules Colors", vbInformation, "Done"
End Sub
See graphic example near by. Of course after I did this, someone said; Can you replicate this for Google Sheets?
|