Share via

How To Copy the ROUND Function

Anonymous
2011-07-28T18:26:22+00:00

I want the formula I have in the cell to stay the same, but I want to add the ROUND function to it.  Is there a way to avoid typing the ROUND function into each cell?  Can I just copy it somehow without altering the formula I have in the cell?

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2011-07-28T18:30:27+00:00

Select the cells and run this - change the 0 to the rounding level you want.

Bernie

Sub AddRounding()

Dim myCell As Range

Dim strForm As String

Application.EnableEvents = False

For Each myCell In Selection

   strForm = Right(myCell.Formula, Len(myCell.Formula) - 1)

   myCell.Formula = "=Round(" & strForm & ",0)"

Next myCell

Application.EnableEvents = True

End Sub

You could also select all the cells, and then apply the rounding to cells with formulas:

Sub AddRounding2)

Dim myCell As Range

Dim strForm As String

Application.EnableEvents = False

For Each myCell In Selection.SpecialCells(xlCellTypeFormulas)

   strForm = Right(myCell.Formula, Len(myCell.Formula) - 1)

   myCell.Formula = "=Round(" & strForm & ",0)"

Next myCell

Application.EnableEvents = True

End Sub

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2012-08-29T15:31:57+00:00

    I have tried the rounding action, and it works, when coupled with the formatting to add the "1:". Now i need to work with it a bit to develop my thinking

    Thank you

    Was this answer helpful?

    0 comments No comments