John Caines
Well-known Member
- Joined
- Aug 28, 2006
- Messages
- 1,155
- Office Version
- 2019
- Platform
- Windows
Hello All.
I have a spreadsheet that I'm creating as a "To Do" spreadsheet.
What I want to be able to do is have macro buttons to clear individual Rows of data.
The rows for data to be cleared will be,,,
E4:P4
E5:P5
E6:P6 (carried on down until),,
E18:P18
(Miss 2 Rows,,)
Then,, E21:P21
going down continuously to
E35:P35
(Miss 2 Rows again)
Then finally E38:P38
going down continuously to
E52:P52
So,, all in all 43 macro clear buttons.
I have a formula that I can assign to 1 which is this;
He's my idea
I have to insert this 43 times into VBA (With amended Range data,, & amended "You want to delete ROW XYZ?,,, statement)........
My idea is,, is there a way to write 1 macro,, that can know if a button is on say ROW 30 it would know to clear just the ROW 30 range (IE E30:P30,,, and ask,,"Are you sure you want to delete ROW 30?"
I think maybe you get the jiest of what I'm saying,, rather than have 43 individual clear macros,, if it could be written into 1?
Thing is,, if it can, I' don't know how
Just an idea anyway.
(Actually,,, I'm just thinking now,, maybe you could have just 1 macro that you could assign just 1 clear macro button to,,, and have a pop up box that said something like,,,
"Insert the row numbers you want to clear"
and then I could just type for example 1,7,9,27,40
Click an OK button,, and it would say,,, "You sure you want to delet these ROWs 1,7,9,27,40?
I click ok,, and it deletes them....
(Just an Idea,,, would be cleaner,, as I wouldn't then have 43 macro clear buttons on my sheet)
I hope the above makes sense.
Many thanks
John Caines
I have a spreadsheet that I'm creating as a "To Do" spreadsheet.
What I want to be able to do is have macro buttons to clear individual Rows of data.
The rows for data to be cleared will be,,,
E4:P4
E5:P5
E6:P6 (carried on down until),,
E18:P18
(Miss 2 Rows,,)
Then,, E21:P21
going down continuously to
E35:P35
(Miss 2 Rows again)
Then finally E38:P38
going down continuously to
E52:P52
So,, all in all 43 macro clear buttons.
I have a formula that I can assign to 1 which is this;
Code:
Sub RowClear()
If WorksheetFunction.CountA(Range("E4:P4")) = 0 Then
MsgBox "No Data in ROW 4 to delete..."
Else
If MsgBox("Are you sure you want to delete ROW 4?", vbYesNo + vbCritical) = vbYes Then
Range("E4:P4").ClearContents
End If
End If
End Sub
He's my idea
I have to insert this 43 times into VBA (With amended Range data,, & amended "You want to delete ROW XYZ?,,, statement)........
My idea is,, is there a way to write 1 macro,, that can know if a button is on say ROW 30 it would know to clear just the ROW 30 range (IE E30:P30,,, and ask,,"Are you sure you want to delete ROW 30?"
I think maybe you get the jiest of what I'm saying,, rather than have 43 individual clear macros,, if it could be written into 1?
Thing is,, if it can, I' don't know how
Just an idea anyway.
(Actually,,, I'm just thinking now,, maybe you could have just 1 macro that you could assign just 1 clear macro button to,,, and have a pop up box that said something like,,,
"Insert the row numbers you want to clear"
and then I could just type for example 1,7,9,27,40
Click an OK button,, and it would say,,, "You sure you want to delet these ROWs 1,7,9,27,40?
I click ok,, and it deletes them....
(Just an Idea,,, would be cleaner,, as I wouldn't then have 43 macro clear buttons on my sheet)
I hope the above makes sense.
Many thanks
John Caines