Clear data by clicking command button

bhandari

Active Member
Joined
Oct 17, 2017
Messages
359
i have data for A2:AD150
i want to clear all the data with macro by pressing command button
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Re: how to clear data by clicking command button

To clear A2:AD150 that is located on the active sheet, try...

Code:
Range("A2:AD150").Clear

To clear A2:AD150 that is located on another sheet (ie. Sheet2), try...

Code:
Worksheets("Sheet2").Range("A2:AD150").Clear

To clear just the contents, replace Clear with ClearContents.

Hope this helps!
 
Upvote 0
Re: how to clear data by clicking command button

To clear A2:AD150 that is located on the active sheet, try...

Code:
Range("A2:AD150").Clear

To clear A2:AD150 that is located on another sheet (ie. Sheet2), try...

Code:
Worksheets("Sheet2").Range("A2:AD150").Clear

To clear just the contents, replace Clear with ClearContents.

Hope this helps!

hey i want to clear only values, and formulas in those range..your code clearing format too
 
Upvote 0
Re: how to clear data by clicking command button

As I stated in my post, to clear just the contents, replace Clear with ClearContents...

Code:
Range("A2:AD150").ClearContents
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,178
Members
452,615
Latest member
bogeys2birdies

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