Consulting

Results 1 to 3 of 3

Thread: Solved: Userform value problem

  1. #1

    Solved: Userform value problem

    I have a little UserForm designed to fill the numerical values ​​into the starting balance for the 3 accounts in an accounting sheet.

    The userform has 3 text boxes for entering starting balance, and 3 command buttons (Register - Empty user form - Close).

    In the text boxes I enter the amount that will be the beginning balance.
    In Denmark we use a comma as decimal delimiter.
    When the value is transferred to the sheet, Excel sees numbers with comma as if it were text.

    If I enter the amount with sentences as decimal delimiter , Excel sees it as a decimal so it will be formatted correctly.

    Here are the userforms VBA code:
    [vba]
    Private Sub CommandButton1_Click()
    Sheets("Ark2").Range("B2") = T1.Value
    Sheets("Ark2").Range("B3") = T2.Value
    Sheets("Ark2").Range("B4") = T3.Value

    Sheets("Ark2").Range("D2") = T1.Value
    Sheets("Ark2").Range("D3") = T2.Value
    Sheets("Ark2").Range("D4") = T3.Value

    End Sub

    Private Sub CommandButton2_Click()
    Me!T1 = ""
    Me!T2 = ""
    Me!T3 = ""
    End Sub

    Private Sub CommandButton3_Click()
    Hide
    End Sub.Select[/vba]
    What should I do to be able to insert the numbers in my language (Danish) and have them transferred correctly to the spreadsheet?
    I am using Excel 2003.

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    try
    [VBA]Sheets("Ark2").Range("B2") = csng(T1.Value) [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    That works.
    Thanks.

Posting Permissions

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