+ Reply to Thread
Results 1 to 7 of 7

Decimal when transferring data to userform

  1. #1
    Forum Contributor
    Join Date
    09-02-2013
    Location
    London
    MS-Off Ver
    Excel 2019
    Posts
    368

    Decimal when transferring data to userform

    Hello,

    Upon transferring the data from a worksheet to a userform. The currency value has dropped but also, the real value with all decimals dropped when I format the textbox value and add the pound sign.

    What I would like to achieve is to keep the real cell value with all its decimal to the userform without loosing any decimal but, as I formatted on the worksheet, showing only 2 decimal.

    These are the two codes I came up so far

    Please Login or Register  to view this content.
    or

    Please Login or Register  to view this content.
    [ can be reduced to "£#,##0.00" but then will loose the four decimal value if applicable]

    As you can see from the result below, the currency is missing on the textbox next to the May 2018 and on the second, unless I have the four decimal displayed, because if I formatted it to 2 then the real value with 4 decimal will be gone. So that will create discrepancy in the calculation. (e.g. textbox next to Jan 2019).

    I very much appreciate your help on this. Thank you.

    example.PNG

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

    Re: Decimal when transferring data to userform

    Use the Text property of the range(s) you are getting the value(s) from to get the formatted value and use that to populate the textbox.

    Store the actual value, without currency symbol but with correct decimal places, in the Tag property of the textbox.
    Please Login or Register  to view this content.
    You could then use the value in the Tag property for any calculations.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    09-02-2013
    Location
    London
    MS-Off Ver
    Excel 2019
    Posts
    368

    Re: Decimal when transferring data to userform

    Hi Norie,
    Thank you for this. I think it did job.
    Does it mean however that I have to do the same 'with' code for all 12 textboxes as per the image above or is there a better way of doing so?

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

    Re: Decimal when transferring data to userform

    You wouldn't necessarily need the With part, you could do it like this.
    Please Login or Register  to view this content.
    There's also the option of not using the Tag property to store the 'real' value and instead referring back to the cell that the textbox was populated from when you want to do calculations.

  5. #5
    Forum Contributor
    Join Date
    09-02-2013
    Location
    London
    MS-Off Ver
    Excel 2019
    Posts
    368

    Re: Decimal when transferring data to userform

    Thanks. I will try that.

    I've written something like this for all 12 textboxes but I think the syntax is incorrect. Would it be appropriate?

    Please Login or Register  to view this content.

  6. #6
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,517

    Re: Decimal when transferring data to userform

    Please Login or Register  to view this content.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  7. #7
    Forum Contributor
    Join Date
    09-02-2013
    Location
    London
    MS-Off Ver
    Excel 2019
    Posts
    368

    Re: Decimal when transferring data to userform

    Thanks for everyone's help. It did work.

+ 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] Prevent Duplicate Entries in Excel Worksheet While Transferring Data from UserForm
    By rakotonirinas in forum Excel Programming / VBA / Macros
    Replies: 32
    Last Post: 11-23-2018, 07:24 PM
  2. Transferring data from userform to specific cells
    By Flexecel22! in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-05-2016, 02:11 AM
  3. Editing data in userform and transferring back into row it came from
    By NellieNoggs in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-05-2014, 06:53 AM
  4. [SOLVED] Need help transferring data from a userform to worksheet depending on a combobox selection
    By Annamarie in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-08-2014, 11:11 AM
  5. [SOLVED] Re :Userform Data not Transferring to Worksheet
    By Janto724 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-13-2013, 10:57 AM
  6. Transferring Data from Userform Listbox to Drop-down list in Worksheet
    By f5awp in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-30-2011, 12:22 AM
  7. UserForm transferring data
    By mariapata1974 in forum Excel General
    Replies: 8
    Last Post: 03-28-2010, 11:18 AM

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