+ Reply to Thread
Results 1 to 15 of 15

Textbox decimal value to cell formula

  1. #1
    Registered User
    Join Date
    07-24-2011
    Location
    Brasov
    MS-Off Ver
    Excel 2010
    Posts
    18

    Textbox decimal value to cell formula

    Hi everybody!

    I have the following code:

    Please Login or Register  to view this content.
    If I run this code it gives me a Runtime error '1004': Aplication-defined or object-defined error, and marks the codeline where I want to add the Textbox value to the cell formula.

    If I remove the formatting Sub, and enter an integer value, then everything works great, but when I introduce the formatting option or a decimal number the problem starts again.

    How can I solve this problem?

    Thanks in advance for your help.
    Last edited by bgabi89; 04-10-2017 at 05:14 PM.

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Textbox decimal value to cell formula

    Try adding .value

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Registered User
    Join Date
    07-24-2011
    Location
    Brasov
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Textbox decimal value to cell formula

    Still debug error at this line:

    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Textbox decimal value to cell formula

    The problem is when you have number long enough to have thousands separator.

    use
    Please Login or Register  to view this content.
    or don't use thousands separator at all in the formatting sub
    If you are pleased with a member's answer then use the Star icon to rate it.

  5. #5
    Registered User
    Join Date
    07-24-2011
    Location
    Brasov
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Textbox decimal value to cell formula

    @buran

    I tried your version but still Debug error, even if I don't use thousands. It works only when I use whole numbers, and in the rest, Debug error. It's starting to annoy me this error

  6. #6
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Textbox decimal value to cell formula

    I was able to reproduce your error and posted the solution for it. Upload your workbook if you want further assistance.

  7. #7
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Textbox decimal value to cell formula

    Hi,

    What is the decimal separator on your computer and what is the actual value in the textbox?
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  8. #8
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Textbox decimal value to cell formula

    @xlnitwit is right - the decimal separator could be a reason too.

  9. #9
    Registered User
    Join Date
    07-24-2011
    Location
    Brasov
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Textbox decimal value to cell formula

    This is my workbook.

    My PC local settings for decimal is "," and for digit grouping is "."
    Excel has the same setting.
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Textbox decimal value to cell formula

    My solution with converting the textbox value to Double works just fine. I changed my regional settings to match yours and it works.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    07-24-2011
    Location
    Brasov
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Textbox decimal value to cell formula

    @buran:

    Now it works fine, but only with whole numbers. If I try with decimal numbers I get debug error, I don't know why.

    I give up, because I'm tired trying and I dpn't know whats the problem is. I'm thinking of this for 4 days, this is the fifth day

  12. #12
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Textbox decimal value to cell formula

    As I said, with your regional settings my file works just fine with decimal numbers.

  13. #13
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Textbox decimal value to cell formula

    Are you entering the decimal numbers in the textbox using a comma for the decimal point, or a dot?

  14. #14
    Registered User
    Join Date
    07-24-2011
    Location
    Brasov
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Textbox decimal value to cell formula

    These are my regional settings.

    When I enter in the textbox the value (i.e. 15 dot 14) separated by dot the fist Sub will change to 1514,00 (1514 comma 00) , and will add to the cell 1514 instead of 15,14
    Attached Images Attached Images

  15. #15
    Registered User
    Join Date
    07-24-2011
    Location
    Brasov
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Textbox decimal value to cell formula

    I managed to solve the problem by simply adding a Replace function
    Last edited by bgabi89; 04-11-2017 at 04:17 PM.

+ 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. Textbox to accept integers or decimal numbers only
    By Bob@Sun in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-23-2017, 03:51 AM
  2. [SOLVED] Only allowing numbers and decimal in a textbox
    By DannyJ in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-28-2016, 03:01 AM
  3. problem with input decimal numbers into a textbox
    By Röbke in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-16-2016, 06:41 PM
  4. Userform textbox output to one decimal place
    By Tubes2015 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-18-2015, 11:12 AM
  5. [SOLVED] Have formula results/textbox to round value at 0 decimal places
    By Groovicles in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-13-2015, 09:58 AM
  6. Textbox decimal numbers
    By mqdias in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-09-2007, 01:02 PM
  7. Textbox value decimal problem
    By mqdias in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-22-2007, 09:30 AM

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