# Microsoft Office Application Help - Excel Help forum > Excel Programming / VBA / Macros >  >  Clear sheet in VBA

## Sasolini

Hey,

Can someone pls tell me how to write a code for deleting/clearing entire sheet. I want to make sure that the sheet is totaly empty, so i would like to cleare it before i start my program.

Can someone pls tell me that?

Thx

----------


## EMoe

Hello Sasolina,

Try this:

Sub test()
    Cells.Select
    Selection.ClearContents
    Range("A1").Select
End Sub

Regards,
EMoe

----------


## nosferer

With this in mind, how would one clear two non adjacent rows, or an array of cells in nonadjacent cells?

----------


## EMoe

Hello,

*Cells.Select*, selects the entire worksheet, right? 

Selection.clear would probably be better than Selection.ClearContents, but you can clear cell formats.

It should clear (I think) everything on the sheet, except for objects like arrows or shapes.

Also, Sasolini, sorry for the name misspell.

Regards,
EMoe

----------


## bhofsetz

You could also use 

Selection.Delte

if you want to remove contents AND formatting to completely clear the sheet.

----------


## bhofsetz

nosferer,

select your rows or ranges as follows then delete them all together.
This example deletes rows 37 and 39
You could do the same with ranges

Sub DeleteRows()
Range("37:37,39:39").Delete
End Sub

HTH

----------

