good evening everybody,
I am trying to figure out a way to delete data from cells but to keep the formulas.
This is the macro I am using
"Private Sub BtnNew_Click()
Sheet1.Range("A2:T2,V2,X2,Y2,Z2,AA2,AB2,AC1,AD1,AE1,AC2,AD2,AE2,AF2").Select
Range("AF2").Activate
Selection.SpecialCells(xlCellTypeConstants, 3).Select
Selection.ClearContents
Sheet1.Range("A2") = ""
Sheet1.Range("B2") = ""
Sheet1.Range("C2") = ""
Sheet1.Range("D2") = ""
Sheet1.Range("E2") = ""
Sheet1.Range("F2") = ""
Sheet1.Range("G2") = ""
Sheet1.Range("H2") = ""
Sheet1.Range("J2") = ""
Sheet1.Range("K2") = ""
Sheet1.Range("L2") = ""
Sheet1.Range("M2") = ""
Sheet1.Range("N2") = ""
Sheet1.Range("O2") = ""
Sheet1.Range("P2") = ""
Sheet1.Range("Q2") = ""
Sheet1.Range("R2") = ""
Sheet1.Range("S2") = ""
Sheet1.Range("T2") = ""
Sheet1.Range("V2") = ""
end sub"
The problem is that when the cells contain no data I get an error message.
Any help will be highly appreciated
Attached please find the test file I am working on
Thank you all
Bookmarks