ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   Rounding-Formulas (https://www.excelbanter.com/new-users-excel/87826-rounding-formulas.html)

fak119

Rounding-Formulas
 
Is there (or can there be) a macro or a function that changes a formula like

=C1*$R4 in =round(C1*$R4;0) etc.

I have many spreadsheets with hundreds of formulas on each sheet that need
to be rounded. I would have to change individually every single formula. Is
there an easier way?


Niek Otten

Rounding-Formulas
 
Depending on how you formatted the cells, you might consider

ToolsOptionsCalculation tab, check Precision as displayed. Look in HELP to read the consequences.

--
Kind regards,

Niek Otten

"fak119" wrote in message ...
| Is there (or can there be) a macro or a function that changes a formula like
|
| =C1*$R4 in =round(C1*$R4;0) etc.
|
| I have many spreadsheets with hundreds of formulas on each sheet that need
| to be rounded. I would have to change individually every single formula. Is
| there an easier way?
|



JE McGimpsey

Rounding-Formulas
 
One way:

Public Sub WrapARound()
Const sWRAPPER As String = "=Round(#; 0)"
Dim ws As Worksheet
Dim rFormulae As Range
Dim rCell As Range
For Each ws In ActiveWorkbook.Worksheets
On Error Resume Next 'in case no formulae
Set rFormulae = ws.Cells.SpecialCells(xlCellTypeFormulas)
On Error GoTo 0
If Not rFormulae Is Nothing Then
For Each rCell In rFormulae
With rCell
If Not .Formula Like "=ROUND(*" Then _
.Formula = Replace( _
sWRAPPER, "#", Mid(.Formula, 2))
End With
Next rCell
End If
Set rFormulae = Nothing
Next ws
End Sub


In article ,
fak119 wrote:

Is there (or can there be) a macro or a function that changes a formula like

=C1*$R4 in =round(C1*$R4;0) etc.

I have many spreadsheets with hundreds of formulas on each sheet that need
to be rounded. I would have to change individually every single formula. Is
there an easier way?



All times are GMT +1. The time now is 03:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com