View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.worksheet.functions
mateo mateo is offline
external usenet poster
 
Posts: 8
Default applying rounding formula to entire worksheet

Thanks for that Macropod, I should have mention the text titles. For some
reason when running your new macro after selecting everything it either says
"this macro requires merge cells to be of the same size." Or when just
selecting numbers, it make each row contain the same number as the first cell
in each row.


"macropod" wrote:

Hi mateo,

Had you mentioned there being an issue with text & values being interspersed, I might have suggested using:

Sub RoundDownRange()
Dim OldVal As Object
Dim NewVal As String
For Each OldVal In Selection
If Application.WorksheetFunction.IsNumber(OldVal.Valu e) Then
NewVal = OldVal.Formula
If Left(NewVal, 1) = "=" Then
NewVal = Right(NewVal, Len(NewVal) - 1)
End If
NewVal = "=ROUND(" & NewVal & ",-1)-1"
OldVal.Formula = NewVal
End If
Next OldVal
End Sub

Although the code does what you asked for, the results are a bit odd (ie -1) if the starting value is less than 5.

Cheers

--
macropod
[MVP - Microsoft Word]