+ Reply to Thread
Results 1 to 7 of 7

Formatting Multiple Userform Textboxes

  1. #1
    Registered User
    Join Date
    02-01-2010
    Location
    Stirling, Scotland
    MS-Off Ver
    Excel 2013
    Posts
    21

    Formatting Multiple Userform Textboxes

    Hi All,

    I have more than 50 textboxes on my userform but i need to format them to number as 0.00. Is there any way to do all 50 boxes at once rather than 1 line of code per box?

    Any help would be great.

    Thanks,

    Si
    Last edited by badeye; 04-01-2010 at 09:18 AM.

  2. #2
    Valued Forum Contributor JeanRage's Avatar
    Join Date
    03-02-2009
    Location
    Nice, France
    MS-Off Ver
    Excel 2003
    Posts
    705

    Re: Formatting Multiple Userform Textboxes

    Hi,
    Please Login or Register  to view this content.
    HTH

  3. #3
    Registered User
    Join Date
    02-01-2010
    Location
    Stirling, Scotland
    MS-Off Ver
    Excel 2013
    Posts
    21

    Re: Formatting Multiple Userform Textboxes

    Can't get it working, What am i doin wrong?

    Code:

    Private Sub CommandButton1_Click()

    Dim i As Integer
    For i = 1 To 5

    Me.Controls("TextBox" & i).Value = Format(Me.Controls("TextBox" & i).Value, "0.00")

    Next i

    Me.TextBox1.Value = Range("A2")
    Me.TextBox2.Value = Range("B2")
    Me.TextBox3.Value = Range("C2")
    Me.TextBox4.Value = Range("D2")
    Me.TextBox5.Value = Range("E2")



    End Sub

  4. #4
    Valued Forum Contributor JeanRage's Avatar
    Join Date
    03-02-2009
    Location
    Nice, France
    MS-Off Ver
    Excel 2003
    Posts
    705

    Re: Formatting Multiple Userform Textboxes

    Hi,
    Please Login or Register  to view this content.
    HTH

  5. #5
    Registered User
    Join Date
    02-01-2010
    Location
    Stirling, Scotland
    MS-Off Ver
    Excel 2013
    Posts
    21

    Re: Formatting Multiple Userform Textboxes

    Hi,

    The formatting still isnt working, please see the attached form.

    Please note: the attached for is just me testing the code and not the actual form it will be used on as the actual form is too big to upload onto here.
    Attached Files Attached Files

  6. #6
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Formatting Multiple Userform Textboxes

    I'm just learning this stuff myself but shouldn't the formatting happen AFTER the values come in. In other words have:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    02-01-2010
    Location
    Stirling, Scotland
    MS-Off Ver
    Excel 2013
    Posts
    21

    Re: Formatting Multiple Userform Textboxes

    Hi,

    In the end i did this and it worked.

    "
    Private Sub CommandButton1_Click()

    Dim i As Integer


    Me.TextBox1.Value = Range("A2")
    Me.TextBox2.Value = Range("B2")
    Me.TextBox3.Value = Range("C2")
    Me.TextBox4.Value = Range("D2")
    Me.TextBox5.Value = Range("E2")

    For i = 1 To 5

    Me.Controls("TextBox" & i) = Format(Me.Controls("TextBox" & i).Value, "0.00")

    Next i

    End Sub
    "

    Thanks,

    Si

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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