SUM textbox Values within frame

mhe5026

New Member
Joined
Jun 25, 2014
Messages
5
I set up a grid of 12 x 12 textboxes within a frame, so (144 individual boxes) that allow a user to input a number. I was unsure if there was another way of summing the values together in that frame without doing, Val(textbox1) + Val(textbox2) + Val(textbox3)... Also, this is all within a user form, not in excel, the input data will be implemented into excel later. I am making a calculator of sort.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Try something like this...

<font face=Calibri><SPAN style="color:#00007F">Dim</SPAN> Ctrl <SPAN style="color:#00007F">As</SPAN> Control<br><SPAN style="color:#00007F">Dim</SPAN> MySum <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Double</SPAN><br><br>MySum = 0<br><SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> Ctrl <SPAN style="color:#00007F">In</SPAN> Me.Frame1.Controls<br>    <SPAN style="color:#00007F">If</SPAN> TypeName(Ctrl) = "TextBox" <SPAN style="color:#00007F">Then</SPAN><br>        MySum = MySum + Val(Ctrl.Value)<br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br><SPAN style="color:#00007F">Next</SPAN> Ctrl<br><br>MsgBox MySum<br>    </FONT>

Hope this helps!
 
Upvote 0
yes it worked great! only thing is what if i want the summed value to go into a textbox on the userform somewhere else, not in that frame instead of the message box.
 
Upvote 0
Try...

Code:
Me.TextBox145.Value = MySum

Change the name of the textbox, accordingly.

Hope this helps!
 
Upvote 0
That's great, I'm glad you've figured it out.

Cheers!
 
Upvote 0

Forum statistics

Threads
1,215,429
Messages
6,124,839
Members
449,193
Latest member
MikeVol

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