Adding Round funciton to handful of numbers

J

JoeU2004

Rick Rothstein said:
Okay, I'm confused again.

You're fine. Take a deep breath. I think you are getting confused by
postings that are crossing on the Internet, as well as other factors that I
will not mention to be polite ;).

In the posting timestamped 12:14p, Jamie explained exactly what is needed,
to wit: given a cell with a constant, change it to a formula of the form
=ROUND(constant,-2).

In the posting timestamped 12:23p, you provided exactly the right solution.
Problem solved. End of thread. Whew!

But to explain the confusion....

In the posting timestamped 12:27p, Jamie responded to your 12:10p response
to me in which you acknowledged that formatting alone would not solve the
problem.

Jamie then tried to explain __kind__ of solution he/she is expecting by
showing a solution to a __previous__ problem.

In the previous problem, someone had a formula in the cell, not a constant,
so of course the solution used MID(...,2,...) to strip off the formula's "="
to form the new formula, =ROUND(formula,-2).

Jamie misspoke when he/she wrote that the previous formula "does exactly
what I need". Of course, that formula does __not__ work when there is a
constant in the cell because there is no "=" to strip off. That is why
Jamie was seeking a solution to "this posting" (i.e. the topic of this
thread).

Arguably, the simplest solution is to change MID(...,2,...) to
MID(...,1,...). But of course, Rick's solution is more straight-forward for
that case.

Rick, I hope I have resolved your confusion.

Jamie. I think it would be sufficient for you to acknowledge that Rick's
posting timestamped 12:23p is all you need, and the problem is solved.


----- original message -----
 
B

Bernd P

Hello Jamie,

Maybe

Sub addround2()
Dim cell As Range
For Each cell In Selection
If Not cell.HasFormula And IsNumeric(cell) Then
cell = "=ROUND(" & cell.Text & ",-2)"
End If
Next cell
End Sub

You have raw data and you do not want to change any formula (or apply
this macro repeatedly), I guess.

Regards,
Bernd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top