Function to generate random colors. Also, can specifically exclude list of colors from list. Additionally, added macro to generate reference table of colors.
Enjoy....
Code
Public pubPrevColor As Integer ' Set as public so value is remembered
Function intRndColor()
'USE - FUNCTION TO PICK RANDOM COLOR, ALSO ALLOWS EXCLUSION OF COLORS YOU DON'T LIKE
Dim Again As Label
Again:
intRndColor = Int((50 * Rnd) + 1) 'GENERATE RANDOM IN
Select Case intRndColor
Case Is = 1, 3, 21, 35, 36 'COLORS YOU DON'T WANT
GoTo Again
Case Is = pubPrevColor
GoTo Again
End Select
pubPrevColor = intRndColor 'ASSIGN CURRENT COLOR TO PREV COLOR
End Function
Sub ViewColors()
'USE THIS TO VIEW COLORS, PICK COLORS YOU DON'T WANT FOR RANDOM COLOR GENERATOR
Dim x As Integer
Sheets.Add
Cells(1, 1).Value = "Color Index#"
Cells(1, 2).Value = "Color Sample"
For x = 2 To 58
Cells(x, 1).Value = x - 2
Cells(x, 2).Select
With Selection.Interior
.ColorIndex = x - 2
.Pattern = xlSolid
End With
Next x
Cells.Select
Cells.EntireColumn.AutoFit
With Selection
.HorizontalAlignment = xlCenter
End With
Cells(1, 1).Select 'GO HOME
End Sub
Display More
[hr]*[/hr] Auto Merged Post Until 24 Hrs Passes;[dl]*[/dl]Note, Random color generator can be set to 56....