Newb needs macro help with button and clearing multiple cells

dwaynet19

New Member
Joined
Dec 3, 2009
Messages
21
It amazes me how simple these issues come to some and how difficult they are for others. As much as I have tried and tried, macros are not my friend.

I am working on a mac. (excel for mac 2011)

I have a calculator type file which calculates totals 3 different columns.
I want to create a button which when I click, clears all the entries on all 3 different columns.
What do I need to do?

Scenario:

B2 = Button (when I click the button I want to clear the following)
B5,H5,N5 Individual cells to clear
D5;D23 J5;J23 P5;P23 columns I want to clear
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Try on a copy of your sheet:

Code:
Sub ClearCells()
    Dim myArea As Range
    For Each myArea In Range("B5,H5,N5,D5:D23,J5:J23,P5:P23").Areas
        myArea.ClearContents
    Next
End Sub
 
Upvote 0
Hi

Try this.

Sub ClearCells()
Range(B5, H5, N5).Clear
Range(D5, D23, J5, P23, P5, P23).Clear
End Sub
 
Upvote 0
Hashiru.....
I did not try your macro.
What is the difference from yours and the first posted by Nalani?

Is there a difference?
 
Upvote 0
Developer Ribbon > Insert > Button > Place button on worksheet > double click button > copy + paste code into the code editor > go back to worksheet > disable design mode by clicking on it on the developer ribbon > click on your button > scream
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,850
Members
452,948
Latest member
UsmanAli786

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