Consulting

Results 1 to 2 of 2

Thread: Using Excel type formulae in VBA Forms

  1. #1
    VBAX Newbie
    Joined
    Jul 2008
    Location
    Sheffield
    Posts
    3
    Location

    Using Excel type formulae in VBA Forms

    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.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    TextBox9.Value = Application.Sum(Arr)
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •