Article ID: 192906
Article Last Modified on 9/12/2006
Sub ColorIndexList()
' Begin error trapping.
On Error GoTo Done
Range("A1").Select
' Put the word Color in active cell.
ActiveCell.Formula = "Color"
' Put the words Color Index Number one cell to right of active cell.
ActiveCell.Offset(0, 1).Formula = "Color Index Number"
' Select one cell down from active cell.
ActiveCell.Offset(1, 0).Activate
' Begin loop from 1 to 56.
For Color = 1 To 56
' Apply color and pattern properties to active cell.
With ActiveCell.Interior
.ColorIndex = Color
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
' Put color index in cell to right of active cell.
ActiveCell.Offset(0, 1).Formula = Color
' Select next cell down.
ActiveCell.Offset(1, 0).Activate
' Increment For loop.
Next Color
Done:
End Sub
163435 VBA: Programming Resources for Visual Basic for Applications
Additional query words: XL98
Keywords: kbhowto kbprint kbdtacode KB192906