LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Userform and Text Box

Thanks for the reply.

When I run the codes, they put values from textboxes 2 and
3 side by side as text like 100200 instead of summing up
to 300. Any idea why. Thank you so much for your help.

-----Original Message-----
Jamie,

Using the Change events from the textboxes, you can call

a routine that adds
up specific textboxes and plop that value in another.

Here's an example
where code behind the form totals up textboxes 2,3 & 4

and displays them in
TextBox1. It assumes that the controls that you want

summed up (2,3,4 in
this case) have a Tag property that equals the

word "sum". To add more
controls, simply add them and give them a "sum" tag and

add the ReCalc
routine to their Change event.

Sub ReCalc()
Dim ctl As Control
Dim dValue As Double

For Each ctl In Me.Controls
If ctl.Tag = "sum" Then
dValue = dValue + Val(ctl.Value)
End If
Next

TextBox1.Value = dValue

End Sub

Private Sub TextBox2_Change()
ReCalc
End Sub

Private Sub TextBox3_Change()
ReCalc
End Sub

Private Sub TextBox4_Change()
ReCalc
End Sub



--
Charles
www.officezealot.com


"Jamie" wrote in

message
...
I have a userform with quite a few text boxes where
numerical values are entered (with decimal points). I

want
to use one of the text boxes on the same userform to

show
a running total of the values entered in other text

boxes.
Is there a way of doing this? Thanks is advance.



.

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
UserForm text will not wrap pgarcia Excel Discussion (Misc queries) 1 September 11th 07 11:44 PM
Userform List box to Text Box hazel Excel Discussion (Misc queries) 1 September 16th 06 07:05 PM
format userform text box Zygan Excel Discussion (Misc queries) 3 July 12th 06 03:25 PM
userform text boxes Jo[_4_] Excel Programming 4 September 23rd 03 03:38 AM
Userform text box John Wilson Excel Programming 0 September 10th 03 07:31 PM


All times are GMT +1. The time now is 07:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"