0
I was using this Sub Clearcontents to clean up all the content I had in the Sheets, I need to add an exception that is the G1 cell and I found this other Sub, but I don’t know how to mix the two
Sub ClearContents()
Application.Calculation = xlManual
Application.ScreenUpdating = False
Sheets("01-Janeiro").Cells.Delete
Sheets("02-Fevereiro").Cells.Delete
Sheets("03-Março").Cells.Delete
Sheets("04-Abril").Cells.Delete
Sheets("05-Maio").Cells.Delete
Sheets("06-Junho").Cells.Delete
Sheets("07-Julho").Cells.Delete
Sheets("08-agosto").Cells.Delete
Sheets("09-Setembro").Cells.Delete
Sheets("10-Outubro").Cells.Delete
Sheets("11-Novembro").Cells.Delete
Sheets("12-Dezembro").Cells.Delete
Application.ScreenUpdating = True
End Sub
Sub ClearAllExceptSelection()
'updateby Extendoffice 20151113
Dim xRg As Range
Dim xCell As Range
Dim xAddress As String
Dim xUpdate As Boolean
On Error Resume Next
xAddress = Application.ActiveWindow.RangeSelection.Address
Set xRg = Application.InputBox("Please select the ranges want to keep", "Kutools for Excel", xAddress, , , , , 8)
If xRg Is Nothing Then Exit Sub
xUpdate = Application.ScreenUpdating
Application.ScreenUpdating = False
For Each xCell In ActiveSheet.UsedRange
If Intersect(xCell, xRg) Is Nothing Then
xCell.Clear
End If
Next
Application.ScreenUpdating = xUpdate
End Sub
I need to erase everything in the sheet and keep G1 intact and if you also know how to apply it in this function would help me
Public Function SheetClear(Name As String)
Dim s As Worksheet, t As String
Dim i As Long, k As Long
k = ThisWorkbook.Sheets.Count
For i = k To 1 Step -1
t = ThisWorkbook.Sheets(i).Name
If t = Name Then
Application.DisplayAlerts = False
ThisWorkbook.Sheets(i).Cells.Delete
Application.DisplayAlerts = True
End If
Next i
End Function