Reset excel sheet (Clean completely)

I was searching a way in which I could delete all the content that I have in an excel sheet, so I came across this VBA code:

Sub ClearSheet()
Sheets("Sheet1").Cells.Clear
End Sub

However, I realized that this code was not going to work for me since in the excel sheets I also have objects that are not inside the cells, such as images and objects. Is there a way where I can do a type of reset on the excel sheet and clean it completely?

just delete the sheet and recreate it is that ok?

    Application.DisplayAlerts = False
    Sheets("Sheet1").Delete
    Dim newSheet As Worksheet
    Set newSheet = ActiveWorkbook.Sheets.Add
    newSheet.Name = "Sheet1"
1 Like

I was trying to avoid that so not to alter the order of the sheets but I suppose that is the only alternative, thank you very much!

1 Like

you could try this if you ONLY have charts and images, but if you have other objects e.g embedded files etc you need to add more for loops to cover each type of object

Dim chtObj As ChartObject
For Each chtObj In ActiveSheet.ChartObjects
chtObj.Delete
Next

Dim Pic As Object
For Each Pic In ActiveSheet.Pictures
Pic.Delete
Next Pic

@JavXult

Sheets("Sheet1").UsedRange.Delete

maybe is doing this

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.