Skip to content

Instantly share code, notes, and snippets.

@brymck
Created September 20, 2012 08:41
Show Gist options
  • Save brymck/3754702 to your computer and use it in GitHub Desktop.
Save brymck/3754702 to your computer and use it in GitHub Desktop.
Color all cell background and foreground indices
' For when you want to preserve color indices when saving from Excel 2007+ to
' .xls format. Copy into PERSONAL.XLS or your worksheet and run with
' Alt+F11, Ctrl+G, ColorCells()
Private Const StartRow As Integer = 2
Private Const StartCol As Integer = 2
Private Const LastColorIndex As Integer = 56
Public Sub ColorCells()
Dim i As Integer
Dim Row As Integer
For i = 0 To LastColorIndex
Row = i + StartRow
Cells(Row, StartCol).Interior.ColorIndex = i
Cells(Row, StartCol + 1).Font.ColorIndex = i
Next i
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment