Clearing Cells using a Macro and a button

hsingh2088

New Member
Joined
May 6, 2011
Messages
35
I've tried at least 4 or 5 different solutions on this forum and none of them have worked. I need to clear contents of cells within a range from rows 12 to 26, then rows 29 to 31 then 33 to 49 then 42 to 43 and columns E through N. I don't need any fancy coloring or anything like that, I just want to clear the contents of the cells. Can someone please show me the code for a sheet called "Summary?"

Thanks
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
If I understand, you want to clear contents of the ranges E12:N26, E29:N31 and E33:N49. Is that right?
If so then this is all you should need.
Code:
Sub ClearMyRanges()
Range("E12:N26, E29:N31, E33:N49").ClearContents
End Sub

Does that help?
 
Upvote 0
I just created a blank work book and randomly filled out the cells and it worked for me; however, when I use it for a different workbook I am trying to make it work for, I get that stupid error. I am not sure what I am missing for the workbook that I want this code to work for..
 
Upvote 0
I am unable to duplicate your error...

Does it work like this
Code:
Sub ClearRanges()
Range("E12:N26").ClearContents
Range("E29:N31").ClearContents
Range("E33:N49").ClearContents
End Sub
 
Upvote 0
I figured it out. Apparently you can't clear merged cells with that code. Do you by any chance know the code that would include having to clear merged cells?
 
Upvote 0

Forum statistics

Threads
1,224,534
Messages
6,179,390
Members
452,909
Latest member
VickiS

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