Glaswegian
09-09-2004, 03:31 AM
I'm sure there is an easy explanation for this, but I can't see it at the moment!
All I'm trying to do is clear some cells and change the interior colour based on the value of a Control Toolbox checkbox. However, I receive an error '1004 - unable to set ColorIndex property of Interior Class'. The code is so simple
Private Sub CheckBox1_Click()
Dim myRange As Range
Set myRange = Worksheets("Sheet7").Range("A1:D1")
If CheckBox1.Value = True Then
With myRange
.Interior.ColorIndex = 6
.Value = ""
End With
End If
End Sub
It works fine if I wrap the ColorIndex line in a single sub.
Sorry if this is a bit stupid but I'm stumped!
Thanks
Iain - XL97 on NT4
All I'm trying to do is clear some cells and change the interior colour based on the value of a Control Toolbox checkbox. However, I receive an error '1004 - unable to set ColorIndex property of Interior Class'. The code is so simple
Private Sub CheckBox1_Click()
Dim myRange As Range
Set myRange = Worksheets("Sheet7").Range("A1:D1")
If CheckBox1.Value = True Then
With myRange
.Interior.ColorIndex = 6
.Value = ""
End With
End If
End Sub
It works fine if I wrap the ColorIndex line in a single sub.
Sorry if this is a bit stupid but I'm stumped!
Thanks
Iain - XL97 on NT4