Is there away I can but a button or something like that

rcirone

Active Member
Joined
Mar 12, 2009
Messages
483
Office Version
  1. 365
Platform
  1. Windows
Is there away I can but a button or something like that. That when press it will clear all content for a lot of cell but they are not all in the same row
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
You can create a button to run any VBA procedure that you create.
All you have to do is create your VBA procedure, and then assign that procedure to a command button (see How To Add A Form Control Button To Run Your VBA Code | How To Excel).

As for creating the VBA code, if you need help with that, you will need to provide a lot more details than you have!
 
Upvote 0
You can create a button to run any VBA procedure that you create.
All you have to do is create your VBA procedure, and then assign that procedure to a command button (see How To Add A Form Control Button To Run Your VBA Code | How To Excel).

As for creating the VBA code, if you need help with that, you will need to provide a lot more details than you have!
I need A4:Q40 and x4:x40 , cells Y4, c154 to c166 I need all the cell I listed to clear all content when I hit the button.

Thanks for your help
 
Upvote 0
Pretty straightforward procedure.
VBA Code:
Sub MyClearCells()
    Range("A4:Q40").ClearContents
    Range("X4:X40").ClearContents
    Range("Y4").ClearContents
    Range("C154:C166").ClearContents
End Sub
If you need to make changes to it, it should be pretty easy to see how to do that.
 
Upvote 0
Solution
You could also do it in one line, like this:
VBA Code:
Sub MyClearCells2()
    Range("A4:Q40, X4:X40, Y4:Y4, C154:C156").ClearContents
End Sub
 
Upvote 0
Pretty straightforward procedure.
VBA Code:
Sub MyClearCells()
    Range("A4:Q40").ClearContents
    Range("X4:X40").ClearContents
    Range("Y4").ClearContents
    Range("C154:C166").ClearContents
End Sub
If you need to make changes to it, it should be pretty easy to see how to do that.
Thanks it works
 
Upvote 0

Forum statistics

Threads
1,215,212
Messages
6,123,655
Members
449,113
Latest member
Hochanz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top