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.
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.