Could anyone help with the following, you may have helped with this code before
Sub NumColors()
Dim x As Integer
Dim i As Integer
Dim ncell As Range
Dim vColors As Variant
vColors = Array(3, 4, 6, 7, 8, 10, 12)
'Cells to enter dates are labeled as a range "NUM"
Range("Num".Select 'Cells to enter dates are labeled as a range "NUM"
For Each ncell In Selection
If ncell.Value <> "" Then ' If cell is blank then it gets skipped
ncell.Interior.ColorIndex = vColors(ncell.Value)
Else
ncell.Interior.ColorIndex = xlNone
End If
Next ncell
End Sub
This line is causing the problem
ncell.Interior.ColorIndex = vColors(ncell.Value)
I get an out of range error if left that way
If i take out the (ncell.value) it colors everything in as 3(red). If i have 100 different values i need them have different colors based on the array? how can i make 100 different ncell values have at least 30-40 different colors based on what i enter in the array??
Thanks for the help.
Ed
Sub NumColors()
Dim x As Integer
Dim i As Integer
Dim ncell As Range
Dim vColors As Variant
vColors = Array(3, 4, 6, 7, 8, 10, 12)
'Cells to enter dates are labeled as a range "NUM"
Range("Num".Select 'Cells to enter dates are labeled as a range "NUM"
For Each ncell In Selection
If ncell.Value <> "" Then ' If cell is blank then it gets skipped
ncell.Interior.ColorIndex = vColors(ncell.Value)
Else
ncell.Interior.ColorIndex = xlNone
End If
Next ncell
End Sub
This line is causing the problem
ncell.Interior.ColorIndex = vColors(ncell.Value)
I get an out of range error if left that way
If i take out the (ncell.value) it colors everything in as 3(red). If i have 100 different values i need them have different colors based on the array? how can i make 100 different ncell values have at least 30-40 different colors based on what i enter in the array??
Thanks for the help.
Ed