I am trying to clear any formulas which result in a value of 0 or "" in a range which is called "_Stacking Plan". The code either stops on the If statement:
Dim c As Range
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
With ThisWorkbook.ActiveSheet.Range("_StackingPlan"): Rem adjust
For Each c In ActiveSheet.Range("_StackingPlan")
With c
If c = 0 Then c.ClearContents
End With
Next c
End With
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
OR, if I add an End If, I get a "compile error: End If without block If":
Dim c As Range
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
With ThisWorkbook.ActiveSheet.Range("_StackingPlan"): Rem adjust
For Each c In ActiveSheet.Range("_StackingPlan")
With c
If c = 0 Then c.ClearContents
End If
End With
Next c
End With
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
I am not a well-versed VBA programmer, so it could be something “obvious”. But, I have tried all kinds of variations on this code. Nothing seems to work.
Bookmarks