The following code clears data in column G and cell K9 within the specified range. How could the code be modified so that it even limits clearing the formulas in column G?
Code: Select all
Sub ClearReport()
Dim wshS As Worksheet
Dim wshT As Worksheet
Dim s As Long
Dim m As Long
Application.ScreenUpdating = False
Application.EnableEvents = False
' Source sheet
Set wshS = Worksheets("Report")
' Get last row
m = wshS.Range("G:G").Find(What:="THANK YOU").Row
For s = 15 To m - 1
If wshS.Range("G" & s).Value <> "Results" Then
wshS.Range("G" & s).ClearContents
Worksheets("Report").Range("K9").ClearContents
End If
Next s
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Thanks in advance.