+ Reply to Thread
Results 1 to 20 of 20

Incorrect Formatting Applied to Data from User Form to Worksheet

  1. #1
    Forum Contributor
    Join Date
    07-13-2014
    Location
    Three Rivers
    MS-Off Ver
    365
    Posts
    127

    Incorrect Formatting Applied to Data from User Form to Worksheet

    Hi

    In my attached sheet I have a user form that extracts data from the FFP worksheet when the user form opens and then you can save data to the FFP worksheet and calculate a value and display the value on the user form itself while the user form is still active.

    I please need help with the following formatting when clicking the CALCULATE and SAVE buttons on the user form:

    1. User Form Data entry fields (3,4,6) are percentage values. The question is how do you keep it as a percentage value when it gets transferred to the FFP worksheet when the user enters either a numerical value e.g. “9” or a percentage value “9%” and then click the calculate button? In other words what would the VBA code say – if a 9 is entered in entry field (3) on the user form then it would convert it to 9% but also if 9% is entered then it would keep it as 9%?

    2. User Form Data entry field (5) is a currency value, but when it is saved to the FFP worksheet by clicking the save or calculate button it saves it as a “text” value and not currency value and therefore the Answer throws out a #VALUE! Error. In the VBA code how do you keep it in currency format?


    Thanks
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Incorrect Formatting Applied to Data from User Form to Worksheet

    What is the decimal separator in your system: "dot" or "comma" ?

  3. #3
    Forum Contributor
    Join Date
    07-13-2014
    Location
    Three Rivers
    MS-Off Ver
    365
    Posts
    127

    Re: Incorrect Formatting Applied to Data from User Form to Worksheet

    It is a "dot"

  4. #4
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Incorrect Formatting Applied to Data from User Form to Worksheet

    For example, for "CalculateButton":

    Due to an undefined security alert, you have the code in the txt file below.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    07-13-2014
    Location
    Three Rivers
    MS-Off Ver
    365
    Posts
    127

    Re: Incorrect Formatting Applied to Data from User Form to Worksheet

    Thanks for the code, this is great! All the "percentage" values work correctly now.

    However, I picked a problem with "Reg7" input field - when you open the User Form and immediately click CalculateButton then it deletes the original value and changes "Reg7" input field to 0 (zero).
    This also happens when you only change any one of the percentage values and click the CalculateButton then it changes the currency field (Reg7) to zero where it should not change this field at all, the original value should remain..

    I really appreciate your help with this!

    I have attached a new workbook that runs your code if you would like to see what it does as I explained above.
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Incorrect Formatting Applied to Data from User Form to Worksheet

    What currency format you have for Reg7/"IncAfterTax"/"Answer" fields (?), how it looks visually (?), make and upload a screenshot.
    With my regional settings I can not reproduce such a situation.

  7. #7
    Forum Contributor
    Join Date
    07-13-2014
    Location
    Three Rivers
    MS-Off Ver
    365
    Posts
    127

    Re: Incorrect Formatting Applied to Data from User Form to Worksheet

    That is strange!

    I am using South Africa region settings but even if I change my region to another country in Control Panel, I still get the same problem...

    When I open the User Form and immediately click the Calculate Button without making any other changes on the User Form, then it changes Reg7 (on user form) and "IncAfterTax" (cell D18) to a zero amount.

    So in my case it shows R0.00 instead of R10,000.00 on both the User Form and the worksheet when I click the Calculate Button but it should continue to show R10,000.00 (or any other currency if changed in Control Panel).

    [EDIT] Image removed
    Last edited by Rudidw; 02-16-2020 at 12:24 PM.

  8. #8
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Incorrect Formatting Applied to Data from User Form to Worksheet

    I did not mean such detailed settings as shown above, but only the appearance of currency values, e.g.:

    10,000,254.25$
    10,000,254.25 $
    $10,000,254.25
    $ 10,000,254.25
    10 125 125.458$
    10 125 125.458 $
    $10 125 125.458
    $ 10 125 125.458
    10.545.547,48 $
    etc.

    So remove these "details" (this image) as soon as possible.


    ...

    Edit:

    And how will it be with it ?
    Attached Files Attached Files
    Last edited by mjr veverka; 02-16-2020 at 12:27 PM.

  9. #9
    Forum Contributor
    Join Date
    07-13-2014
    Location
    Three Rivers
    MS-Off Ver
    365
    Posts
    127

    Re: Incorrect Formatting Applied to Data from User Form to Worksheet

    Quote Originally Posted by porucha vevrku View Post
    I did not mean such detailed settings as shown above, but only the appearance of currency values, e.g.:

    10,000,254.25$
    10,000,254.25 $
    $10,000,254.25
    $ 10,000,254.25
    10 125 125.458$
    10 125 125.458 $
    $10 125 125.458
    $ 10 125 125.458
    10.545.547,48 $
    etc.

    So remove these "details" (this image) as soon as possible.
    Ah OK... I removed the image

    I am using excel 365 but when I run the same worksheet on another computer using Excel 2010 It also does the same thing

  10. #10
    Forum Contributor
    Join Date
    07-13-2014
    Location
    Three Rivers
    MS-Off Ver
    365
    Posts
    127

    Re: Incorrect Formatting Applied to Data from User Form to Worksheet

    Quote Originally Posted by porucha vevrku View Post
    I did not mean such detailed settings as shown above, but only the appearance of currency values, e.g.:

    10,000,254.25$
    10,000,254.25 $
    $10,000,254.25
    $ 10,000,254.25
    10 125 125.458$
    10 125 125.458 $
    $10 125 125.458
    $ 10 125 125.458
    10.545.547,48 $
    etc.

    So remove these "details" (this image) as soon as possible.


    ...

    Edit:

    And how will it be with it ?
    Thanks I will try this code and let you know shortly

  11. #11
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Incorrect Formatting Applied to Data from User Form to Worksheet

    The differences in regional settings manifest themselves just like that ...

    In the section below (txt file below) you can insert 'Stop' and observe live where in the code there is an inaccuracy in the values - just move the mouse cursor over the variable and you will see its current value.


    PS.:

    I put the code in the txt file because I still get some strange "F@!$@$@$g" message from the firewall, when I try to do it directly in the text of the message using tags.

    : (
    Attached Files Attached Files
    Last edited by mjr veverka; 02-16-2020 at 12:42 PM.

  12. #12
    Forum Contributor
    Join Date
    07-13-2014
    Location
    Three Rivers
    MS-Off Ver
    365
    Posts
    127

    Re: Incorrect Formatting Applied to Data from User Form to Worksheet

    I used this code (FFP_CalculateButton_02.txt‎) and still when I initialize the User Form and immediately click the Calculate Button without changing any field it changes the R10,000.00 in Reg7 now down to R10 and not R0.00 anymore

  13. #13
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Incorrect Formatting Applied to Data from User Form to Worksheet

    And this is what your currency format looks like => R10,000.00 ?



    Edit:


    With these currency settings everything works fine at me/at my place - see image:
    Attached Images Attached Images
    Last edited by mjr veverka; 02-16-2020 at 01:17 PM.

  14. #14
    Forum Contributor
    Join Date
    07-13-2014
    Location
    Three Rivers
    MS-Off Ver
    365
    Posts
    127

    Re: Incorrect Formatting Applied to Data from User Form to Worksheet

    Quote Originally Posted by porucha vevrku View Post
    And this is what your currency format looks like => R10,000.00 ?
    It actually looks like R10 000.00 (without the comma)

  15. #15
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Incorrect Formatting Applied to Data from User Form to Worksheet

    Everything is working fine too:
    Attached Images Attached Images

  16. #16
    Forum Contributor
    Join Date
    07-13-2014
    Location
    Three Rivers
    MS-Off Ver
    365
    Posts
    127

    Re: Incorrect Formatting Applied to Data from User Form to Worksheet

    Quote Originally Posted by porucha vevrku View Post
    Everything is working fine too:
    Yes I got the same results. I have no idea why it would be doing it's own thing and changing Reg7 value when clicking the Calculate Button without making any input changes or when only changing the "percentage" values and then clicking calculate. None of the "percentage" values change to some strange value when clicking the Calculate Button

    You say you don't get this problem there by you?

  17. #17
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Incorrect Formatting Applied to Data from User Form to Worksheet

    Apparently the differences in system and regional settings are greater/larger than I thought, I can't reproduce this behavior of variable values ​​in my place. If the amendment/correction below doesn't work for you, I'm afraid I won't help you.
    Attached Files Attached Files

  18. #18
    Forum Contributor
    Join Date
    07-13-2014
    Location
    Three Rivers
    MS-Off Ver
    365
    Posts
    127

    Re: Incorrect Formatting Applied to Data from User Form to Worksheet

    Ok thanks for the help and the effort!

    What I have figured out so far:
    1. In region setting in Control panel I have to select the comma under Digit Grouping Symbol then the code works right Showing R10,000.00 and it does not change the value when clicking Calculate Button. If I don't select the comma and have it show R10 000.00 then the code changes the value from R10 000.00 to R10
    2. If I select any other country region in control panel (e.g. United Kingdom or United States) which already has the comma selected under Digit Grouping Symbol then the sheet changes $10,000.00 to $0.00 or £10,000.00 to £0.00 when I click the Calculate Button. I assume this is due to the "static" region setting in the code (see attached)?
    If this is so then nobody from other countries would be able to use this worksheet as it would not work correctly for them and this would not help my future plans with this type of sheet?

    Not sure what else to do now about this code.png

  19. #19
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Incorrect Formatting Applied to Data from User Form to Worksheet

    Quote Originally Posted by Rudidw View Post
    ... If this is so then nobody from other countries would be able to use this worksheet as it would not work correctly for them and this would not help my future plans with this type of sheet? ...
    In the most "drastic cases" ... ... this can happen.
    You must remember that this is not only about the settings of the type: "comma, period, such a currency, other currency" - this also applies to the matrix of characters / code page on which the operating system works.
    English-speaking countries have a different set of characters than, for example, French-speaking, German-speaking, Slavic-speaking, Greek-speaking, etc.

    Try to "practice" your case with the following set of functions in vba - maybe one of them will solve your problem (with your system's regional settings and your code page):
    Attached Files Attached Files

  20. #20
    Forum Contributor
    Join Date
    07-13-2014
    Location
    Three Rivers
    MS-Off Ver
    365
    Posts
    127

    Re: Incorrect Formatting Applied to Data from User Form to Worksheet

    Quote Originally Posted by porucha vevrku View Post
    Apparently the differences in system and regional settings are greater/larger than I thought, I can't reproduce this behavior of variable values ​​in my place. If the amendment/correction below doesn't work for you, I'm afraid I won't help you.
    Thank You, Thank You, Thank You!!!

    This last code of yours works like a charm, does exactly what I want and without any of the previous problems! I have now tested it multiple times and with different regional settings and all works 100%

    That was frustrating but thank you for your persistence to get my vba problem solved, I am truly grateful!!!

+ 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. send data from worksheet to user form
    By msaric in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-18-2013, 04:08 AM
  2. Replies: 1
    Last Post: 08-28-2013, 05:04 PM
  3. [SOLVED] Excel vba user form- open directly to user form not worksheet
    By PANTECH in forum Excel Programming / VBA / Macros
    Replies: 26
    Last Post: 04-24-2013, 05:07 PM
  4. Copying data from one worksheet to another using user form
    By nikadon in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-06-2013, 03:34 PM
  5. Transfer User form data to a worksheet w.r.t. combobox item on the form
    By nm766 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-07-2011, 12:43 PM
  6. Filling form fields via worksheet dropdowns, user update via form, change form color
    By Demosthenes&Locke in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-11-2010, 08:58 AM
  7. Add data from a user form to a new row in a worksheet.
    By LD2020 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-06-2010, 04:11 AM
  8. Entering worksheet data via user form
    By Tellus in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-29-2008, 01:37 PM

Tags for this Thread

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