infinity
10-30-2005, 09:18 PM
Hey all,
I am pretty new to VBA, so I hope someone can help me. I am trying to use and If statement to change the interior color of a group of cells. I am inserting a row at 6:6,then if B7 interior color is grey then I want B6:K6 to be white. If B7 interior color is white, I want B6:K6 to be grey. This is the code I thought I would use for that but I keep getting an error saying that "Object does not support this property or method". Any suggestions? Thank you so much in advance.
Range("B7").Select
If Selection.Interior = ColorIndex = 1 Then
Range("B6:K6").Select
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Range("B7").Select
ElseIf Selection.Interior = ColorIndex = 15 Then
Range("B6:K6").Select
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
End If
I am pretty new to VBA, so I hope someone can help me. I am trying to use and If statement to change the interior color of a group of cells. I am inserting a row at 6:6,then if B7 interior color is grey then I want B6:K6 to be white. If B7 interior color is white, I want B6:K6 to be grey. This is the code I thought I would use for that but I keep getting an error saying that "Object does not support this property or method". Any suggestions? Thank you so much in advance.
Range("B7").Select
If Selection.Interior = ColorIndex = 1 Then
Range("B6:K6").Select
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Range("B7").Select
ElseIf Selection.Interior = ColorIndex = 15 Then
Range("B6:K6").Select
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
End If