ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Change the Value of cell to Whole Number (https://www.excelbanter.com/excel-programming/341350-change-value-cell-whole-number.html)

DKY[_91_]

Change the Value of cell to Whole Number
 

How do I change the value of a cell to a whole number? The closest
thing I can find on the net is int and it says to do like so
int(C1)
So I tried to program that in to my loop where i is equal to the row
number
int("C" & i)
and it says to me
"Compile Error: Expected Identifier"

I'm not even sure if int is what I want to do because after doing
further research on it, it seems that int causes the value to round
down. So a value of 210.832169 will be 210 instead of 211. Anyone
have any insight on what I can search for?


--
DKY
------------------------------------------------------------------------
DKY's Profile: http://www.excelforum.com/member.php...o&userid=14515
View this thread: http://www.excelforum.com/showthread...hreadid=471437


Jim Thomlinson[_4_]

Change the Value of cell to Whole Number
 
Range("A1").Value = CInt(Range("A1").Value)
--
HTH...

Jim Thomlinson


"DKY" wrote:


How do I change the value of a cell to a whole number? The closest
thing I can find on the net is int and it says to do like so
int(C1)
So I tried to program that in to my loop where i is equal to the row
number
int("C" & i)
and it says to me
"Compile Error: Expected Identifier"

I'm not even sure if int is what I want to do because after doing
further research on it, it seems that int causes the value to round
down. So a value of 210.832169 will be 210 instead of 211. Anyone
have any insight on what I can search for?


--
DKY
------------------------------------------------------------------------
DKY's Profile: http://www.excelforum.com/member.php...o&userid=14515
View this thread: http://www.excelforum.com/showthread...hreadid=471437



K Dales[_2_]

Change the Value of cell to Whole Number
 
The error is coming because you are not setting anything equal to int("C" &
i) and you also need to specify (in VBA) that this is a Range address.
Finally, the function you want is Round()
Round(number,decimals) rounds the number to the specified number of
decimals; 0 for a whole number
Range("C" & i).Value = Round(Range("C"&i).Value,0)
--
- K Dales


"DKY" wrote:


How do I change the value of a cell to a whole number? The closest
thing I can find on the net is int and it says to do like so
int(C1)
So I tried to program that in to my loop where i is equal to the row
number
int("C" & i)
and it says to me
"Compile Error: Expected Identifier"

I'm not even sure if int is what I want to do because after doing
further research on it, it seems that int causes the value to round
down. So a value of 210.832169 will be 210 instead of 211. Anyone
have any insight on what I can search for?


--
DKY
------------------------------------------------------------------------
DKY's Profile: http://www.excelforum.com/member.php...o&userid=14515
View this thread: http://www.excelforum.com/showthread...hreadid=471437



DKY[_94_]

Change the Value of cell to Whole Number
 

So, what's the difference between Int and CInt?


--
DKY
------------------------------------------------------------------------
DKY's Profile: http://www.excelforum.com/member.php...o&userid=14515
View this thread: http://www.excelforum.com/showthread...hreadid=471437



All times are GMT +1. The time now is 06:11 PM.

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