Clear The Active Worksheet With a Click of a Button

Many times when we are working on a modelling problem using Microsoft Excel, we might be required to clear the sheet contents. For example, you are just starting out to solve a problem and need to clear the cells without deleting the whole sheet.

Personally, I don’t prefer wasting time on taking my hands to the mouse and then press clear contents.
A better option is to write use some already written VBA macro which can be assigned a shortcut or we can assign this macro to a button on excel sheet. The best part is that using VBA codes, you can achieve a lot such as clearing just the contents, clearing the formatting, clearing everything, clearing the comments etc.


In this example, I have taken a file named “Pattern_Generation.xlsm”. Yes, all the macro enabled excel workbooks should be saved using the extension of xlsm.

Sub clear_all()
' To clear the contents
' To clear everything including the formatting
'To clear only formatting
'To clear the comments
' To clear the outline
End Sub 

It should be noted that the each line of code is preceded with a comment line which says the purpose of each nest line.You can find your purpose and then use that line of code in your VBA Macro to achieve what you want.
Let me know if you feel difficulty in using this code.

Aly Chiman

Aly Chiman is a Blogger & Reporter at which covers a wide variety of topics from local news from digital world fashion and beauty . AlyChiTech covers the top notch content from the around the world covering a wide variety of topics. Aly is currently studying BS Mass Communication at University.

Leave a Reply

Your email address will not be published.