Update Formula

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,

I have lots of formulas in a worksheet. They calculate
sums from other figures. I need to add ROUND function at
the beginning of each of these formulas. e.g. I want to
say =Round(existing formula,0).

To update this manully would take a very long time. Is
there a possibility of automation? Thanks for your help.

Regards,
 
Sub RoundAdd()
Dim myStr As String
Dim cel As Range
For Each cel In Selection
If cel.HasFormula = True Then
If Not cel.Formula Like "=ROUND(*" Then
myStr = Right(cel.Formula, Len(cel.Formula) - 1)
cel.Value = "=ROUND(" & myStr & "," & "0" & ")"
End If
End If
Next
End Sub


Gord Dibben Excel MVP
 
Thanks. Its really helpful. Thank you.
-----Original Message-----
Sub RoundAdd()
Dim myStr As String
Dim cel As Range
For Each cel In Selection
If cel.HasFormula = True Then
If Not cel.Formula Like "=ROUND(*" Then
myStr = Right(cel.Formula, Len (cel.Formula) - 1)
cel.Value = "=ROUND(" & myStr & "," & "0" & ")"
End If
End If
Next
End Sub


Gord Dibben Excel MVP



.
 
Back
Top