Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default 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
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
ROUNDING FORMULA =ROUND(B12/$B$10,1) ROUNDING TO HIGH SunshineinFt.Myers[_2_] Excel Worksheet Functions 7 March 5th 09 06:41 PM
how copy formula that contains ranges so ranges do not overlap Patty Excel Worksheet Functions 1 November 20th 08 04:15 PM
I need a formula with rounding up & rounding down to the nearest . Tony Kay Excel Worksheet Functions 3 May 29th 07 11:13 PM
Rounding results by ranges mmarley50 Excel Worksheet Functions 3 November 2nd 06 08:45 PM
named ranges - changing ranges with month selected gr8guy Excel Programming 2 May 28th 04 04:50 AM


All times are GMT +1. The time now is 08:24 PM.

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

About Us

"It's about Microsoft Excel"