PDA

View Full Version : Using Excel type formulae in VBA Forms



Bramo
07-11-2008, 08:54 AM
Okay I've tried my best to fix this all afternoon. My grasp of VBA is fairly basic at the moment but heres the problem:
I have a user form with 8 textboxes that take numeric values 0-10. There is then a 9th textbox which should show the sum of these 8 other textboxes, but I cant seem to get it to work. I know this would be easier in excel itself (using SUM(C1:C6) etc....), but I need it to be shown on the form.
Heres the code which doesn't work! ::

Dim Arr(8)

Arr(1) = TextBox1.Value
Arr(2) = TextBox2.Value
Arr(3) = TextBox3.Value
Arr(4) = TextBox4.Value
Arr(5) = TextBox5.Value
Arr(6) = TextBox6.Value
Arr(7) = TextBox7.Value
Arr(8) = TextBox8.Value

TextBox9.Value = xlSum = Arr(8)

I'm lost! Help would be most grateful.

Bob Phillips
07-11-2008, 09:15 AM
TextBox9.Value = Application.Sum(Arr)