I put 5 textboxes on a user form.
I was careful to name the first four nicely:
TextBox1 through TextBox4
Then I could use that in the code:
Option Explicit
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Call doSumTB5
End Sub
Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Call doSumTB5
End Sub
Private Sub TextBox3_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Call doSumTB5
End Sub
Private Sub TextBox4_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Call doSumTB5
End Sub
Sub doSumTB5()
Dim iCtr As Long
Dim myTotal As Double
myTotal = 0
For iCtr = 1 To 4
With Me.Controls("textbox" & iCtr)
If IsNumeric(.Value) Then
myTotal = myTotal + CDbl(.Value)
End If
End With
Next iCtr
Me.TextBox5.Value = Format(myTotal, "#,##0.000")
End Sub
Private Sub UserForm_Initialize()
Me.TextBox5.Locked = True
End Sub
=======
Have you thought of making the 5th textbox a label (or at least locking the
textbox)--some kind of protection from the user???
funkymonkUK wrote:
hey
I have 5 text boxes which 1 of them has to be a running total of what
has been entered in. what I tried linking the 5 textboxs to a cell and
then for the one that i want to have the total in i have made its value
= cell however this does not seem to update. any ideas? i dont want the
user to input this textbox so i disabled it will that make a
difference??
Any help will be appreicated
--
funkymonkUK
------------------------------------------------------------------------
funkymonkUK's Profile: http://www.excelforum.com/member.php...o&userid=18135
View this thread: http://www.excelforum.com/showthread...hreadid=345880
--
Dave Peterson