Need a rounding Macro

dustinp43

New Member
Joined
Jul 11, 2006
Messages
21
Hello, I have a bunch of cells that have numbers that aren't rounded, and I need to round them all to zero, but I still need to show the work, so I need to go into each cell and manually add in the round function.

For example,

If the cell was previously 400*(1.0204/.9709)...I am manually going into each cell and changing the cell text to =round(400*(1.0204/.9709),0). I tried to record a macro doing this, but the macro is taking the text in the cell and applying it generally, so it doesn't work because not all of the cells have the same values.


' Keyboard Shortcut: Ctrl+e
'
ActiveCell.Select
ActiveCell.FormulaR1C1 = "=ROUND(400*(1.0204/0.9709),0)"
ActiveCell.Select
End Sub


Basically I want a macro that will put the cursor in the front of the formula and add the "Round(" and then go to the end of the formula and add ",0)"

Is this possible?

Thanks for your help guys
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Select your range first then run:

Sub Round()

Dim c As Range

For Each c In Selection
c.Formula = "=round(" & Right(c.Formula, Len(c.Formula) - 1) & ",0)"

Next c

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,595
Messages
6,179,798
Members
452,943
Latest member
Newbie4296

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