How To Delete Cell Content In Excel With Simple VBA

Do you do the same thing over and over again in Excel, want to get automating with some simple macros and VBA, here is a great one to get started.

Lost of people would either use the same template or Excel worksheet and manually select the cells to clear by highlighting them.  Here is a great way with a simple piece of VBA to automate this procedure if you always  delete the same cells – like I do then this small piece of code will do the trick

Option Explicit

Sub  ClearCell()

Selection.Clear

‘ The above clears all cells, but you can if specify a range that you regularly delete for example’

 ‘  substitute the “Selection” for “Range(“A1:D5″)”, or your suitable’

‘  range.’

 End Sub

It is really easy to install this piece of code.

  1. Open Excel
  2. Right click on the sheet you want to install the code in
  3. Hit view code
  4. Copy the code above and paste it into the window where the cursor is flashingClose the VBA window

In my example I have chosen to delete A2 to D5, this way I can keep my column headings as I re use these over and over again.

Give this one a go and let us know how much time you save?


Do you know another way to do this?- share it with other Excellers……….

Other Excel Tips You Might Like

1.Protect An Excel Workbook

2. Number rows in an Excel Table

3. Delete values form cells but keep formulas

4. Transpose Excel data from rows to columns in a flash!


Comments

    • Barbara says

      Angelica

      Yes It could be attached to a Command Button
      Just Create A button and assign the Macro You created to it. Should be good to go.
      Regards
      Barbara

Leave a Reply

Your email address will not be published. Required fields are marked *