Excel TextBox Calculation

momo007

New Member
Joined
Jul 10, 2004
Messages
33
Hi all, I have an Excel form with a number of textboxes (eg, textbox1, textbox2, textbox 3 etc).
I would like to add a textbox at the bottom of the form to automatically sum the above textboxes...

eg bottomTextBox = textbox1 + textbox2 + .... etc

how could I do this without a button? Not sure which textbox event this is related to...

Thanks for your help in advance!
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
It all depends when you want to do the sum.

If you want to do it once a value has been entered into a particular textbox then you should probably use that textbox's Exit event to do the calculation.
 
Upvote 0
I need the bottom textbox to automatically update the total whenever the value of any of the other textboxes have been changed....
 
Upvote 0
You say you have a number of textboxes, textbox1, textbox2, textbox 3 etc, and so the first question is, what do you mean by "a number of" and "etc"? Just say it, how many do you have and what are their names? And what is your userform's name?

The reason why this is the first issue is, it'd be good to know whether you need a class module if you have 200 text boxes, or not if you have just 3 or 4. I would not use the Exit event in any case, just a Change event for each one (or a class event for all) to have the "sum" text box show the calculation.

Which brings us to the last point, why do you want to use a text box to show the sum when a label caption would be a better control, if all you want to do is show the sum.
 
Upvote 0
Thanks Tom, didn't think of doing it in labels - may try this option.

The number of textboxes is not fixed, i use VB to generate these textboxes depending on another user input. Say the user wants to enter 10 items, then there'll be 10 textboxes. I'll need to sum these textboxes to give a total.

Any other suggestions please let me know! Thank you all for your help.
 
Upvote 0
I assume you are using an Integer variable based on some factor to create the TextBoxes, because you'd need to know how many to create. Can you post the code you are using to create those textboxes on the fly, and can you post the name of your userform.
 
Upvote 0
For counter = 1 To numClasses
Set tbAcB = frmEntry.mainFrame.Controls.Add("forms.textbox.1")
With tbAcB
.Left = margin + 230
.Top = (curRow * 14)
.Height = 15
.Width = 50
.Name = "drText" & curRow
'.Value = counter '******
End With
curRow = curRow + 1
Next counter

** mainFrame is the name of the frame.
** numClasses is the number of textboxes to be created.

Thanks Tom.
 
Upvote 0

Forum statistics

Threads
1,203,481
Messages
6,055,657
Members
444,806
Latest member
tofanexcel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top