Macro which enter zeros is slow; need help to speed it up
Posted by Veronica P. on February 13, 2001 9:48 AM
I created this macro that in myselection will find cells that do not have formulas or text, but only numbers and if the number is <>0 it will replace the number with zeros.
I do not know what is wrong with it but it is very slow; even if I select only 100 cells with probably only 10 cells with formulas and 20 cells that are not zero, it takes for ever to run. Can it be optimized? Thanks for any help.
Sub enterzero()
Dim myselection As range
Set myselection = Selection
On Error Resume Next
For Each c In myselection
If WorksheetFunction.IsNumber(c) And Not c.HasFormula Then
c.Value = 0
ElseIf (c.HasFormula Or WorksheetFunction.IsText(c)) Then
c.Formula = c.Formula
End If
Next c
End Sub