You have a couple options, such as BeforeDoubleClick and BeforeRightClick, but this comes close too, using SelectionChange. The only thing is, it will shade cell D12 red not only if someone clicks on it but if they arrow on over to it, which maybe you'd have wanted anyway? Maybe not? See if this works for you...right click on your sheet tab, left click on View code, and paste this in. It toggles the color on and off with the clicks too, which can be changed if need be.
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Not Intersect(Target, Range("D12")) Is Nothing Then
If Target.Interior.ColorIndex = 3 Then
Target.Interior.ColorIndex = 0
Else
Target.Interior.ColorIndex = 3
End If
End If
End Sub
HTH
Tom Urtis
range("d12").Interior.Color = vbRed
Try This
'Save this in ThisWorkbook
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
If ActiveSheet.Name = "Sheet1" Then ActiveCell.Interior.ColorIndex = 3
End Sub
This is set to only affect sheet1 How can I make an If statement or some code: if the user clicks the cell, the cell's interior color will be red. I tried a few thing but they didn't work: range("d12").Interior.Color = vbRed
Kieth see my solution , there is a SheetSelectionChange option
: How can I make an If statement or some code: if the user clicks the cell, the cell's interior color will be red. I tried a few thing but they didn't work
Re: Kieth see my solution , there is a SheetSelectionChange option
Thank you Tom and John the code works great!