+ Reply to Thread
Results 1 to 9 of 9

Userform Textbox to store value in excel the number losing decimal

Hybrid View

  1. #1
    Registered User
    Join Date
    06-26-2014
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    7

    Userform Textbox to store value in excel the number losing decimal

    Hi I really needs help
    If I use the value 0,292 it transfers the correct value 0,292 but in text format and not in number format.
    If I use the value 4,678 it transfers the incorrect value 4 678 without the comma and in number format.
    Dim lastrow As Currency
    lastrow = Sheets("Fire").Range("A" & Rows.Count).End(xlUp).Row
    Cells(lastrow + 1, "Q").Value = Format(Me.[txtRate].Value, "##0.000")
    Moderator Note:

    Pls use code tags around your codes.
    Last edited by Fotis1991; 06-26-2014 at 04:48 AM.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,018

    Re: Userform Textbox to store value in excel the number losing decimal

    Try using CDbl:

    Cells(lastrow + 1, "Q").Value = CDbl(Me.[txtRate].Value)
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Registered User
    Join Date
    06-26-2014
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    7

    Re: Userform Textbox to store value in excel the number losing decimal

    Hi, I tried it and the result was:
    If I use 0.262 it shows in the excel cell 0, instead of 0.262
    If I use 4.678 it shows in the excel cell 5 instead of 4.678

  4. #4
    Registered User
    Join Date
    06-26-2014
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    7

    Re: Userform Textbox to store value in excel the number losing decimal

    Hi, I tried it, but the result remains the same

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,018

    Re: Userform Textbox to store value in excel the number losing decimal

    Is the cell formatted to hide decimal places?
    What are your regional settings set to?

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Userform Textbox to store value in excel the number losing decimal

    Try using Val.
    Dim lastrow As Currency
    lastrow = Sheets("Fire").Range("A" & Rows.Count).End(xlUp).Row
    Cells(lastrow + 1, "Q").Value = Val(Me.[txtRate].Value)
    Cells(lastrow + 1, "Q").NumberFormat = "##0.000"
    If posting code please use code tags, see here.

  7. #7
    Registered User
    Join Date
    06-26-2014
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    7

    Re: Userform Textbox to store value in excel the number losing decimal

    I’m sorry but it’s still not working. What it does, if there is a o before the comma (0.262) it works fine, the moment you use a number with 1 or more before the comma (1.2568 or 4.678) then it move the comma to the back of the number (4 678.0)

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Userform Textbox to store value in excel the number losing decimal

    Can you upload an example workbook?

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

  9. #9
    Registered User
    Join Date
    06-26-2014
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    7

    Re: Userform Textbox to store value in excel the number losing decimal

    Hi I attached file, Thanks so much for your willingness to help
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] UserForm TextBox formats - Display as Decimal, Read as Percent. Possible?
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-12-2013, 11:40 PM
  2. [SOLVED] Convert Userform textbox to decimal number
    By Leandrial in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-27-2012, 02:08 PM
  3. Excel 2007: Userform Textbox Prevent Number as the first entry
    By Hudas in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-20-2012, 02:48 PM
  4. Replies: 3
    Last Post: 05-07-2012, 09:46 PM
  5. Why am I losing macros that I create and store in PERSONAL.XLS?
    By Frustrated in Vegas in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-31-2005, 02:06 PM

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