Clear Content/data input from different Cells with a macro

eChef

Board Regular
Joined
Mar 4, 2010
Messages
55
Hi,

I like to place a macro into my worksheet which when clicked will clear my data input in different cells. I don't know if that is possible, but if it is then please can someone help.

example, I want to clear Cells A2 - A10, and B5 - B10, and D4 - D10, but with a macro, so that I do not have to go every time and manually delete the content.

hope it makes sense,
kind regards,
Matt
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
hi, just to clear the contents, you can do this:

Code:
sub ClearCont()
 range("A1:A10").clearcontents
 range("B1:B10").clearcontents
 range("C1:C10").clearcontents
etc.. 
etc..
etc..
end sub()

remove the ect etc etc piece, or add more ranges if you like - the logic is pretty straightforward
 
Upvote 0
You can clear lots at once if you like. Here's one way:
Code:
Sub Clear_Ranges()
    Const RangesToClear As String = _
        "A2:A10, B5:B10, D4:D10" '<- Add more if you want
    Range(RangesToClear).ClearContents
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,254
Members
452,900
Latest member
LisaGo

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