Sweedler
Board Regular
- Joined
- Nov 13, 2020
- Messages
- 132
- Office Version
- 365
- Platform
- Windows
Hello,
I have a column that consists of either "c" (webding empty box) or "a" (webding checkmark). If the cell contains a "c", which is the default, I want a double click to turn it into an "a", but if there is an "a" then I want it to become a "c" again.
Currently trying to repurpose this, but I am not making any headway. It turns it into an "a" just fine, but that is all that it can do.
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
'~~> Check if the double click happened in Range A1:A10
'~~> Also notice the placement of `Cancel = True`
If Not Intersect(Target, Range("AE12:AE206")) Is Nothing Then
'~~> Check if the cell is empty
If Len(Trim(Target)) = 0 Then
Target.Value = "a"
Cancel = True
'~~> Check if the cell already has X. This is to ensure that
'~~> the cell is not cleared if the user has typed something
'~~> else in the cell.
ElseIf UCase(Trim(Target)) = "c" Then
Target.ClearContents
Cancel = True
End If
End If
End Sub
Cheers
I have a column that consists of either "c" (webding empty box) or "a" (webding checkmark). If the cell contains a "c", which is the default, I want a double click to turn it into an "a", but if there is an "a" then I want it to become a "c" again.
Currently trying to repurpose this, but I am not making any headway. It turns it into an "a" just fine, but that is all that it can do.
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
'~~> Check if the double click happened in Range A1:A10
'~~> Also notice the placement of `Cancel = True`
If Not Intersect(Target, Range("AE12:AE206")) Is Nothing Then
'~~> Check if the cell is empty
If Len(Trim(Target)) = 0 Then
Target.Value = "a"
Cancel = True
'~~> Check if the cell already has X. This is to ensure that
'~~> the cell is not cleared if the user has typed something
'~~> else in the cell.
ElseIf UCase(Trim(Target)) = "c" Then
Target.ClearContents
Cancel = True
End If
End If
End Sub
Cheers