Hi all,
I think this is simple, but I just cannot seem to get it... new(ish) to Excel VBA
I have a cell, when double clicked that cell and the one to its left get altered formatting wise... that works...
But now, if I want the cells to be cleared of the formatting, I would like to be done by using the "ESCAPE" key... this is NOT working....
Would someone be kind enough to point me in the right direction...
Just a note... I had it working with a right click event, but right clicking caused some unforeseen issues therefore I want to assign it to the "ESCAPE" key...
Also, I have a follow-up "bonus" question for the same thing, but perhaps that should be a separate thread...
Thanks,
SF
I think this is simple, but I just cannot seem to get it... new(ish) to Excel VBA
I have a cell, when double clicked that cell and the one to its left get altered formatting wise... that works...
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
Target.Interior.Color = vbYellow
With Target.Offset(0, -1)
.Interior.Color = vbRed
.Font.Color = vbWhite
.Font.Strikethrough = True
End With
End Sub
But now, if I want the cells to be cleared of the formatting, I would like to be done by using the "ESCAPE" key... this is NOT working....
VBA Code:
Private Sub EscapetoRepair()
Application.OnKey "{ESC}", Procedure:="RepairCell"
End Sub
Sub RepairCell()
ActiveCell.Select
ActiveCell.Interior.Color = xlNone
ActiveCell.Value = nil
ActiveCell.Offset(0, -1).Select
With ActiveCell
.Interior.Color = xlNone
.Font.Color = vbBlack
.Font.Strikethrough = False
End With
End Sub
Would someone be kind enough to point me in the right direction...
Just a note... I had it working with a right click event, but right clicking caused some unforeseen issues therefore I want to assign it to the "ESCAPE" key...
Also, I have a follow-up "bonus" question for the same thing, but perhaps that should be a separate thread...
Thanks,
SF