Macro does not clear the contents!
I have a worksheet which has an income and expense analysis for 12 months. I would like to re-use it by keeping the formula and format intact, but clear the contents of each cell. So, if a cell does not have a formula, but has a text or number, it should be clear after I run the macro.
I came up with a simple macro, but did not seem to work, so I have posted the question on the code forum site. I have now two macros in which one of the macro does not seem to have a syntax error, but does not do the job, i.e. it loops through each sheet, but does not clear the contents. The other macro has a syntax error.
Could someone please spot what is wrong with these two codes?
Dim Rng As Range, oCell As Range
Set Rng = Range("A2:A100")
For sh = 1 To Worksheets.Count '+for each sheet
For Each oCell In Rng
If oCell.HasFormula Then
Next sh '+
For Each sh In Sheets
sh.Range("A2:A100").SpecialCells(2).clearcontents ‘ a line which shows an error