I noticed that the rules says to not ask for clarification in someone else's question, so hopefully this is the correct way to do it. I initially found enough of an answer to get me where I am at on Change color of cell with mouse click in Excel. Thank you user3159079 and tigeravatar.
I have this:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
Worksheet_SelectionChange Target
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'If the target cell is clear
If Target.Interior.ColorIndex = xlNone Then
'Then change the background to the specified color
Target.Interior.ColorIndex = 4
'But if the target cell is already the specified color
ElseIf Target.Interior.ColorIndex = 4 Then
'Then change the background to the specified color
Target.Interior.ColorIndex = 6
'But if the target cell is already the specified color
ElseIf Target.Interior.ColorIndex = 6 Then
'Then change the background to the specified color
Target.Interior.ColorIndex = 3
'But if the target cell is already the specified color
ElseIf Target.Interior.ColorIndex = 3 Then
'Then clear the background color
Target.Interior.ColorIndex = xlNone
End If
End Sub
but I have 3 problems.
1) I would like to specify a few ranges that this works without affecting other cells (i.e. I would like it to work on...
$F$4:$F$6
$D$10:$I$12
$F$17:$I$34
$N$5:$O$6
$N$10:$O$11
$O$15:$P$18
$O$24:$P$24
$O$29:$P$29
$O$34:$P$34
$U$6:$X$7
$U$10:$X$14
$AA$6:$AG$8
$F$38:$F$43
$N$38:$N$44
$E$48:$E$51
$Q$48:$R$51
$X$23:$AG$35
... and nowhere else.
2) I would like this to only work on double click instead of the cell changing on the first single click
3) This works until I save, close and reopen the spreadsheet. After I reopen the worksheet, the color on click functionality goes away.
I am not very savvy on any of this, but I am able to search fairly well, which is how I have gotten this far, but I cannot figure it out any further so any help would be greatly appreciated.