View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone Jim Cone is offline
external usenet poster
 
Posts: 3,290
Default How to Add 21 Textbox values to give the Sum ?

Here is a start...

Function AddThemUp()
Dim objCtrl As msforms.Control
Dim N As Long
For Each objCtrl In Me.Controls
If TypeOf objCtrl Is msforms.TextBox Then
N = N + Val(objCtrl.Value)
End If
Next
MsgBox N
End Function

Private Sub CommandButton1_Click()
Call AddThemUp
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Corey"
wrote in message
I have a userform with 21 textboxes i need to get the Sum of.
How can i code this?
The textboxes are not in indexed in order either.
They a
textbox6
textbox13
textbox22
textbox31
textbox39
textbox48
textbox56
textbox64
textbox72
textbox80
textbox88
textbox96
textbox104
textbox112
textbox120
textbox128
textbox136
textbox144
textbox152
textbox160
&
textbox168

I need to get the sum of ALL these textbox.values to be Calculated and
placed in textbox172 as the user fills in the values in the textboxes above.
Corey....