LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default How do I replace forumulas with the round function in one go

Dana

That is perfect -

Thank you very much

Cheers

GusDubs

"Dana DeLouis" wrote:

... then realise I wish I had entered the "round" function
Also considered a macro ...but don't know how to get this
to work over a large range of formulas.


I have a toolbar button that runs the following code.
Adjust if you always want it to round to 0.

Sub Round_Add()
'// = = = = = = = = = = = = = = = = = = = = = = = = = = =
'// Adds =ROUND( ) to Formulas in current Selection
'// May have more than one area selected
'// Avoids adding Round to beginning if already used
'// = = = = = = = = = = = = = = = = = = = = = = = = = = =

Dim BigRng As Range
Dim Rng As Range
Dim Cell As Range
Dim Equ As String
Dim iRound As Integer

On Error Resume Next
If Not (TypeOf Selection Is Range) Then Exit Sub
Set BigRng = Selection.SpecialCells(xlFormulas)
If BigRng Is Nothing Then Exit Sub

iRound = InputBox("Round to how many digits?", , 2)

Equ = "=Round(#,n_)"
Equ = Replace(Equ, "n_", iRound)

For Each Rng In BigRng.Areas
For Each Cell In Rng.Cells
If Not Cell.Formula Like "=ROUND(*" Then
Cell.Formula = Replace(Equ, "#", Mid$(Cell.Formula, 2))
End If
Next Cell
Next Rng
End Sub

--
HTH. :)
Dana DeLouis
Windows XP, Office 2003


"GusDubs" wrote in message
...
I am constantly working on spreadsheets and then realise I wish I had
entered
the "round" function at the start. Instinctively I thought of Ctrl+H to
replace but can't figure out how you would put a ,0) at the end.
Also considered a macro with typing - F2, Home, =Round(,End, ,0) - but
dont
know how to get this to work over a large range of formulas.
Any help would be appreciated




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
numerical integration integreat Excel Discussion (Misc queries) 4 May 12th 06 02:40 AM
Replace function anandmr65 Excel Discussion (Misc queries) 1 May 10th 06 01:36 PM
The ROUND function Louise Excel Worksheet Functions 3 June 23rd 05 02:45 PM
Automatically up date time in a cell Mark Excel Discussion (Misc queries) 5 May 12th 05 12:26 AM
clock Wildman Excel Worksheet Functions 2 April 26th 05 10:31 AM


All times are GMT +1. The time now is 12:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"