Quick way to add the value in many textboxes in a userform

birdieman

Well-known Member
Joined
Jan 13, 2016
Messages
551
I have a userform in which I need to add the values in about 25 textboxes (there are formatted numbers in the boxes, like $5,000). Is there a quick and easy way to do it without adding one by one (TextBox50 + TextBox52, etc.)? If it helps, the names/labels are all TextBoxXX (XX is a number) and all TextBox numbers are EVEN numbers between 50 and 100. Thanks
 
Last edited:

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,344
Office Version
  1. 365
Platform
  1. Windows
Do you want to add all of the textboxes or is it pairs of textboxes?

Where should the result(s) go?
 

birdieman

Well-known Member
Joined
Jan 13, 2016
Messages
551
I want to add the values in all EVEN textboxes from say Textbox150 to TextBox198 (Textbox 150+ textbox 152 + textbox 154....+TextBox198) and put result in Textbox200
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,344
Office Version
  1. 365
Platform
  1. Windows
Are they all formatted the same?
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,344
Office Version
  1. 365
Platform
  1. Windows
Note I'm asking about formatting because we need to convert the text in the textboxes to numeric to add the values, looping through the textboxes is the easy part.

For example to loop through every even textbox from 150 to 198 we can use this.
Code:
For I = 150 To 198 Step 2
    MsgBox Me.Controls("Textbox" & I).Value
Next I
 

birdieman

Well-known Member
Joined
Jan 13, 2016
Messages
551
yes, all are formatted "$##,##0". Some may not be that long but all are $#.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,668
Messages
5,838,680
Members
430,563
Latest member
Raeyven

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
Top