Results 1 to 6 of 6
  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Add Values in Two TextBoxes (XL97; SR2)

    I would like to accumulate the sum of the values in textbox1 and textbox2 into textbox3 when ever a "Private Sub TextBox_AfterUpdate()" is completed on textbox 1 or 2.

    Any ideas?

    Thanks,
    John

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Add Values in Two TextBoxes (XL97; SR2)

    Are these textboxes on a user form or on a worksheet, and did they come from the Forms or Controls collection?
    Legare Coleman

  3. #3
    4 Star Lounger
    Join Date
    Sep 2002
    Location
    Stafford, Staffordshire, England
    Posts
    585
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Add Values in Two TextBoxes (XL97; SR2)

    Rather inelegant but it works.
    Set the LinkedCell property of TextBox1 and TextBox2 to any two unused cells(they can always be camouflaged or even on a different sheet. In a third cell(eg,C1) type : A1+B1
    In the Private Sub TextBox1_Change() event for the two TextBoxes type:
    TextBox3.Value = Sheets("Sheet1").Range("C1").
    Substitiute your worksheet name and cell addresses.
    <font color=blue><font face="Script MT Bold"><big>Rob</big></font face=script></font color=blue>

  4. #4
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Add Values in Two TextBoxes (XL97; SR2)

    Try

    Private Sub TextBox1_AfterUpdate()
    TextBox3 = Val(TextBox1) + Val(TextBox2)
    End Sub

    and repeat for TextBox2.

    If you want any formatting use

    TextBox3 = Format(Val(TextBox1) + Val(TextBox2), "#,##0")

    replacing "#,##0" with your preferred formatting picture.

    Andrew C

  5. #5
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Add Values in Two TextBoxes (XL97; SR2)

    Legare,

    The textboxes are on a user form and came from the Forms collection.

    John

  6. #6
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Add Values in Two TextBoxes (XL97; SR2)

    See Andrew's reply, he beat me to it.
    Legare Coleman

Posting Permissions

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