-
Solved: Excel on double click event help
I found code that will allow me to doubleclick on any cell within a predefined column (D) and will set the value to "No" if I doubleclick. I am looking for it to do two other things.
1. If I double click on a cell in column D and it changes it to "No" I would also like it to delete the value in the same row in the column to the left (C).
2. If I double click on a cell in the column (D) and it already has the value "No" I would like it to erase the contents of the cell.
Here's the code:
[VBA]Private Sub Worksheet_BeforeDoubleClick( _
ByVal Target As Range, Cancel As Boolean)
Dim rInt As Range
Dim rCell As Range
Set rInt = Intersect(Target, Range("D3200"))
If Not rInt Is Nothing Then
For Each rCell In rInt
rCell.Value = "No"
Next
End If
Set rInt = Nothing
Set rCell = Nothing
Cancel = True
End Sub
[/VBA]
Is this easily doable? (Excel 2007/Windows).
I appreciate any help anyone can offer.
Thanks.
-
Try this:
[VBA]Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("D3:d200")) Is Nothing Then
If Target <> "No" Then
Target = "No"
Target.Offset(0, -1).ClearContents
Else
Target.ClearContents
End If
End If
Cancel = True
End Sub[/VBA]
-
Thank you very much for your help.
Your suggestion worked perfectly.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules