Set multiple values simultaniously in UserFrom

percy83

Active Member
Joined
Mar 11, 2009
Messages
278
Hi all,

I am working on simple freight cost calculator and is currenly designing a simple user form to enter package size and measurements and weight.

It consists of five rows were you can select no of packages, lenght, width and height.
userform.jpg


I also want to set all text boxes to the left as default "1" with the userforminitialize event. I've named them pcs1 to pcs5. How is the best way to set all these values at the same time?

What is the easiest way to make a summary out of this? Is it naming and looping through the different text boxes or does anyone have a better idea?

What I want is total weight and volume.

Thanks for all help I can get!

BR
Percy
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Using a userform at all seems like overkill for this; you could just use worksheet cells and formula.

That said, you can put the initial values in at design time, and that's what will appear when you show the form.
 
Last edited:
Upvote 0
Using a userform at all seems like overkill for this; you could just use worksheet cells and formula.

That said, you can put the initial values in at design time, and that's what will appear when you show the form.


I totally get your point but this is a part of an application and this uf is triggered with a button if you have more then one parcel.

Also, what is the easiest way to get total weight and volume based on the uf solution?

Thanks!
 
Upvote 0
I also want to set all text boxes to the left as default "1" with the userforminitialize event. I've named them pcs1 to pcs5. How is the best way to set all these values at the same time?
You could set them now as the default values. Set the text property of the controls in the Properties Window to 1.
 
Upvote 0
You could set them now as the default values. Set the text property of the controls in the Properties Window to 1.


Perfect, thanks. Do you think it is easier to make the summary with formulas in the userform itself of is it betterto export the individual values to a sheet in the workbook and make the summary there?

Thanks!
 
Upvote 0
I would want to put these functions in the userform code module, adjusting the control names to meet your situation.
Code:
Function TotalVolume() As Double
    TotalVolume = Val(tbxHeight1.Text) * Val(tbxWidth1.Text) * Val(tbxDepth1.Text) * Val(pcs1.Text)
    TotalVolume = TotalVolume + Val(tbxHeight2.Text) * Val(tbxWidth2.Text) * Val(tbxDepth2.Text) * Val(pcs2.Text)
    TotalVolume = TotalVolume + Val(tbxHeight3.Text) * Val(tbxWidth3.Text) * Val(tbxDepth3.Text) * Val(pcs3.Text)
    TotalVolume = TotalVolume + Val(tbxHeight4.Text) * Val(tbxWidth4.Text) * Val(tbxDepth4.Text) * Val(pcs4.Text)
    TotalVolume = TotalVolume + Val(tbxHeight5.Text) * Val(tbxWidth5.Text) * Val(tbxDepth5.Text) * Val(pcs5.Text)
End Function

Function TotalWeight() As Double
    TotalWeight = Val(tbxWeight1.Text) * Val(pcs1.Text) + Val(tbxWeight2.Text) * Val(pcs2.Text) _
                   + Val(tbxWeight3.Text) * Val(pcs3.Text) + Val(tbxWeight4.Text) * Val(pcs2.Text) _
                   + Val(tbxWeight5.Text) * Val(pcs5.Text)
End Function
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,616
Messages
6,179,908
Members
452,949
Latest member
beartooth91

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