+ Reply to Thread
Results 1 to 4 of 4

Change the Value of cell to Whole Number

  1. #1
    Forum Contributor
    Join Date
    09-19-2004
    Posts
    252

    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?

  2. #2
    Jim Thomlinson
    Guest

    RE: 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
    >
    >


  3. #3
    K Dales
    Guest

    RE: 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
    >
    >


  4. #4
    Forum Contributor
    Join Date
    09-19-2004
    Posts
    252
    So, what's the difference between Int and CInt?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1