ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Zero Decimal Places (https://www.excelbanter.com/excel-programming/312217-zero-decimal-places.html)

Blue

Zero Decimal Places
 
I have the following
sqmrc1 = Range("K1").Value / 1000
Which is used later
Cells(ActiveCell.Row, ActiveCell.column + 1).Value = sqmrc1

I have found how to divide sqmrc1 but how do I make the result to zero
decimal places?

Thanks Blue



Jim Thomlinson[_3_]

Zero Decimal Places
 
Two possible answers depending on how much accuray you want to maintain.

format(sqmrci, "0")

or

round(sqrmc1, 0)

Hope this helps...

"Blue" wrote:

I have the following
sqmrc1 = Range("K1").Value / 1000
Which is used later
Cells(ActiveCell.Row, ActiveCell.column + 1).Value = sqmrc1

I have found how to divide sqmrc1 but how do I make the result to zero
decimal places?

Thanks Blue




Blue

Zero Decimal Places
 
Jim thanks for the reply

I have tried various ways of using Format(sqmrc1, "0") but get an error
message or result is zero. How/where do I attached
Format(sqmrc1, "0") to sqmrc1 = Range("K1").Value / 2

Thanks Blue




John Green[_4_]

Zero Decimal Places
 
Cells(ActiveCell.Row, ActiveCell.column + 1).Value = Format(sqmrc1,"0")

or

ActiveCell.Offset(0,1).Value = Format(sqmrc1,"0")

or

ActiveCell(1,2).Value = Format(sqmrc1,"0")


"Blue" wrote in message
k...
Jim thanks for the reply

I have tried various ways of using Format(sqmrc1, "0") but get an error
message or result is zero. How/where do I attached
Format(sqmrc1, "0") to sqmrc1 = Range("K1").Value / 2

Thanks Blue






Blue

Zero Decimal Places
 
John,

Cells(ActiveCell.Row, ActiveCell.column + 1).Value = Format(sqmrc1,"0")

Did the trick, Thanks

Blue




All times are GMT +1. The time now is 07:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com