John Caines
Well-known Member
- Joined
- Aug 28, 2006
- Messages
- 1,155
- Office Version
- 2019
- Platform
- Windows
Hello All.
I'm just trying to get a double click clear Macro to run on my worksheet.
The formula I have is;
I'm sure this was written some time ago by a guy called Krishnakumar.
Many thanks again.
I don't know if I've inadvertently altered it,, not sure.
I'll link to a sample sheet.
Basically I would just like it to work clearing rows of data,, C5:Q5
when you double click a pop up appears,,,
& you can manually enter the row numbers (Row numbers by the numbers in Column B (B5:B44),, not the cell row numbers)
If anybody understands VB here, please,,
It's above me.
Here's the link to a test spreadsheet.
http://dl.dropbox.com/u/16052166/Double_Click_Macro.xlsm
Many thanks for all your time
I hope somebody can fix it.
Best Regards
John Caines
I'm just trying to get a double click clear Macro to run on my worksheet.
The formula I have is;
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim RowsToClear As String
Dim x, i As Long, y
Dim AllRowsAddress As String
Dim RowAdjust As Long
Const RowsToExclude As String = "{1,2,3,19,20,36,37,54}"
AllRowsAddress = "C5:C44" '<<=== adjust to suit
RowsToClear = Application.InputBox("Enter the rows separated by comma", "Clear Rows", "1,7,9", Type:=1 + 2)
If RowsToClear = "False" Then Exit Sub
RowAdjust = Range(AllRowsAddress).Row - 1
If MsgBox("Are You Sure You Want To Delete These ROWs " & vbLf & RowsToClear & " ?", vbYesNo + vbInformation) = vbYes Then
x = Split(RowsToClear, ",")
On Error Resume Next
For i = 0 To UBound(x)
y = Evaluate("=match(" & CLng(x(i)) & "," & AllRowsAddress & ",0)")
If Not IsError(y) Then
Application.Intersect(Range("c:q"), Rows(x(i) + RowAdjust)).ClearContents
End If
Next
On Error GoTo 0
End If
End Sub
Many thanks again.
I don't know if I've inadvertently altered it,, not sure.
I'll link to a sample sheet.
Basically I would just like it to work clearing rows of data,, C5:Q5
when you double click a pop up appears,,,
& you can manually enter the row numbers (Row numbers by the numbers in Column B (B5:B44),, not the cell row numbers)
If anybody understands VB here, please,,
It's above me.
Here's the link to a test spreadsheet.
http://dl.dropbox.com/u/16052166/Double_Click_Macro.xlsm
Many thanks for all your time
I hope somebody can fix it.
Best Regards
John Caines