Need to remove Round Formula from a Formula which has a Round Function

savioxfernandes

New Member
Joined
Apr 7, 2015
Messages
2
HI

i currently have the beow code which can add an round formula to an Exiting formula in a cell

Code:
Sub add_round()
Dim rng As Range
    For Each rng In Selection
        rng.Value = "=Round(" & Mid(rng.Formula, 2, 9999) & ",2)"
       Next rng


End Sub

however i need to undo this -

meaninig
if the result of the above code give me "=round ((Sum(A1+A2),2) =24.44
then i need to remove the round form the formula in an range

thanks
Savio Fernandes
 
Last edited by a moderator:

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
You could use something like this:

Code:
Sub remove_round()
    Dim rng As Range, formulasRange As Range
    Dim theFormula As String
    
    On Error Resume Next
    If Selection.Cells.Count > 1 Then
        Set formulasRange = Selection.SpecialCells(xlCellTypeFormulas)
    Else
        Set formulasRange = Selection
    End If
    On Error GoTo 0
    
    If Not formulasRange Is Nothing Then
        Application.ScreenUpdating = False
        For Each rng In formulasRange.Cells
            theFormula = rng.Formula
            If UCase$(Left$(theFormula, 7)) = "=ROUND(" Then
                theFormula = "=" & Mid(rng.Formula, 8)
                theFormula = Left$(theFormula, InStrRev(theFormula, ",") - 1)
                rng.Formula = theFormula
            End If
        Next rng
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,286
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top