Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 5 of 5

Thread: Textbox - Easy One (Hopefully)

  1. #1
    New Member
    Join Date
    Feb 2002
    Location
    Washington State
    Posts
    33
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I have a userform in which one of the text boxes displays information from a particular cell on the worksheet. I have formatted the cell in question to only display integer, ie no decimal places, but when the value is imported into the textbox, the textbox displays 8 decimal places. How do I display only the characters to the left of the decimal point in the textbox? The code is below, but is pretty simple actually.

    TextBox3.Value = Range("d4")

    Thanks for any help,

    Rick

  2. #2
    MrExcel MVP Russell Hauf's Avatar
    Join Date
    Feb 2002
    Location
    Portland, OR Area - USA
    Posts
    1,607
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-02-26 12:38, RWinfield wrote:
    I have a userform in which one of the text boxes displays information from a particular cell on the worksheet. I have formatted the cell in question to only display integer, ie no decimal places, but when the value is imported into the textbox, the textbox displays 8 decimal places. How do I display only the characters to the left of the decimal point in the textbox? The code is below, but is pretty simple actually.

    TextBox3.Value = Range("d4")

    Thanks for any help,

    Rick
    Try this:

    TextBox3.Value = Range("d4").Text

    HTH,

    Russell

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Location
    Chippenham, UK
    Posts
    144
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-02-26 12:38, RWinfield wrote:
    I have a userform in which one of the text boxes displays information from a particular cell on the worksheet. I have formatted the cell in question to only display integer, ie no decimal places, but when the value is imported into the textbox, the textbox displays 8 decimal places. How do I display only the characters to the left of the decimal point in the textbox? The code is below, but is pretty simple actually.

    TextBox3.Value = Range("d4")

    Thanks for any help,

    Rick
    TextBox3.Value = Int(Range("D4").value)


    Regards,

    Gary Hewitt-Long

  4. #4
    Board Regular
    Join Date
    Feb 2002
    Location
    Chippenham, UK
    Posts
    144
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    My last post didn't take into account the fact that if you have set the cell format to not show any numbers after the decimal point, the number in the sheet may be rounded up.

    Try this:

    MyInteger = Range("D4").Text ' Converts to text
    MyInteger = Int(MyInteger) ' converts back to an integer.
    TextBox1.Value = MyInteger

    Regards,

    Gary Hewitt-Long

  5. #5
    New Member
    Join Date
    Feb 2002
    Location
    Washington State
    Posts
    33
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Works perfect Gary, thanks!

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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