I am attempting to program an excell sheet so that some of the rows change one set of colors when selected while the rest of the rows will change a different set of colors.
Example:
Rows 1,3,5,9 will change red, then, bule, then green
Rows 2,4,6,8 will change Purple, then yellow when clicked.
This is what I have done so far:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
' This subroutine colors a cell red when double-clicked then clears it when double-clicked again.
' Some values for .ColorIndex are...
' Red = 3, Green = 4, Blue = 5, Yellow = 6, Orange = 45
' Google "VBA color palette" for more colors
' If the cell is clear
If Target.Interior.ColorIndex = xlNone Then
' Then change the background color to red
Target.Interior.ColorIndex = 21
' Else if the cell background color is red
ElseIf Target.Interior.ColorIndex = 21 Then
' Then clear the background
Target.Interior.ColorIndex = 23
' Else if the cell background color is red
ElseIf Target.Interior.ColorIndex = 23 Then
' Then change the background color to red
Target.Interior.ColorIndex = 10
' Else if the cell background color is red
ElseIf Target.Interior.ColorIndex = 10 Then
' Then clear the background
Target.Interior.ColorIndex = xlNone
End If
'
Bookmarks