+ Reply to Thread
Results 1 to 4 of 4

UserForm Textbox Sum Help

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    440

    UserForm Textbox Sum Help

    Hi,

    I want to know if its possible for the TextBox3 to automatically SUM the TextBox1 and TextBox2, without having to go on it and press 0.

    Here is the sample:
    UserformTest.xlsm

    Help anyone?

    Thanks.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: UserForm Textbox Sum Help

    Hi, calvinle,

    maybe just like this:
    Private Sub TextBox1_Change()
    TextBox3 = Val(TextBox1) + Val(TextBox2)
    End Sub
    Private Sub TextBox2_Change()
    TextBox3 = Val(TextBox1) + Val(TextBox2)
    End Sub
    Maybe IŽd go with the Exit-Event instaed of the Change.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    440

    Re: UserForm Textbox Sum Help

    Genius! But what should be the code for the Exit Event?

    Thanks.

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: UserForm Textbox Sum Help

    Hi, calvinle,

    Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    TextBox3 = Val(TextBox1) + Val(TextBox2)
    End Sub
    
    Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    TextBox3 = Val(TextBox1) + Val(TextBox2)
    End Sub
    You could close Textbox3 in order to avoid the user to click into the control.

    Ciao,
    Holger

+ 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. Replies: 4
    Last Post: 01-29-2014, 05:53 AM
  2. Userform to search textbox value to place other textbox values in worksheet
    By mattyh555 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-19-2012, 11:38 AM
  3. Replies: 3
    Last Post: 05-07-2012, 09:46 PM
  4. Userform Textbox updating a another userform textbox (im stuck!!)
    By wapwap in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-31-2011, 02:56 PM

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