Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Rounding Ranges
I am just curious if anyone knows how to either do a global round or do
a round of each of the cells in a range. I currently have the following code in place but it only rounds the active cell. Sub Round() ActiveCell = Application.Round(ActiveCell, -3) / 1000 End Sub Sub ConfirmRound() YesNo = MsgBox("Clicking Yes will...", vbYesNo + vbCritical, "WARNING!!!") Select Case YesNo Case vbYes Call Round Case vbNo End Select End Sub I am also curious what is the code so when a user opens excel, they are taken to a certain location no matter what location was saved prior. Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Rounding Ranges
The following code has worked well for me. It adds the ROUND formula to any
cell. FIrst select the range you want to round and then run the macro. Sub Roundit() On Error GoTo ErrorHandler Roundto = InputBox("Round to How many Places?", "Round!", 0) Roundto = CLng(Roundto) For Each Cell In Selection Rawnum = Cell.Formula If Left(Rawnum, 6) = "=ROUND" Then Cell.Formula = Left(Rawnum, Len(Rawnum) - 2) & Roundto & ")" Else: Rawnum = IIf(Left(Rawnum, 1) = "=", Right(Rawnum, Len(Rawnum) - 1), Rawnum) Cell.Formula = "=round(" & Rawnum & "," & Roundto & ")" End If Next Cell ErrorHandler: End Sub "jdawg" wrote: I am just curious if anyone knows how to either do a global round or do a round of each of the cells in a range. I currently have the following code in place but it only rounds the active cell. Sub Round() ActiveCell = Application.Round(ActiveCell, -3) / 1000 End Sub Sub ConfirmRound() YesNo = MsgBox("Clicking Yes will...", vbYesNo + vbCritical, "WARNING!!!") Select Case YesNo Case vbYes Call Round Case vbNo End Select End Sub I am also curious what is the code so when a user opens excel, they are taken to a certain location no matter what location was saved prior. Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
ROUNDING FORMULA =ROUND(B12/$B$10,1) ROUNDING TO HIGH | Excel Worksheet Functions | |||
how copy formula that contains ranges so ranges do not overlap | Excel Worksheet Functions | |||
I need a formula with rounding up & rounding down to the nearest . | Excel Worksheet Functions | |||
Rounding results by ranges | Excel Worksheet Functions | |||
named ranges - changing ranges with month selected | Excel Programming |