Results 1 to 2 of 2

Getting values from dynamic textboxes on userform in array

Threaded View

  1. #1
    Registered User
    Join Date
    11-16-2014
    Location
    Netherlands
    MS-Off Ver
    2010
    Posts
    5

    Getting values from dynamic textboxes on userform in array

    Hi people!

    I have a table with the following:

    - Rows starting from A2 until whatever amount of kids that are in a class (variable)
    - Questions ranging from D1 until "x"1 with x being whatever value is in cell AL30

    I dynamically populate a userform with the names of the kids on the left, and after every name an amount textboxes corresponding with the number in cell AL30. This lets me score every question of a test for every kid in a class.

    So far... so good. Now the read out part. I want the values that I put in the textboxes (numbers of course, since they are points) to be put in an array on whatever sheet.

    This is my code so far, but I am kinda stuck.

    Private Sub CommandButton1_Click()
    Dim ct As Control, t As Long
     t = Sheets("Sheet1").Range("AL30").Value
    ReDim arr(0 To (Range("A" & Rows.Count).End(xlUp).Row - 1), 0 To (t - 1))
     With Sheets("Scores")
    For Each ct In Controls
      If TypeName(ct) = "TextBox" Then
            Do Until .Cells(n + 1, 1) <> ""
              For j = 0 To t - 1
                arr(n, j) = ""
              Next j
                 n = n + 1
                 j = 0
            Loop
     
        arr(n, i) = TextBox.Value
            i = i + 1
        If i = t Then
          n = n + 1
          i = 0
        End If
      End If
    Next ct
      .Range("B1").Resize(n, t).Value = arr
      End With
    Me.Hide
    End Sub
    Ofcourse the length of the array has to correspond to how many questions there are (in Cell AL30) and the height has to correspond to how many kids there are in clas (The count from A2 until the last filled cell in column A).

    I am unsure what to do with the arr() statements

    Also... I am unsure to what will happend with the array when there are empty textboxes and the "save" button is clicked. I can imagine a user putting in results of kids and having to close halfway...

    Any thoughts?

    Thanks!
    Last edited by nasdrasil; 11-27-2014 at 11:28 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Referencing UserForm TextBoxes in an array?
    By msk37 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-19-2014, 05:22 PM
  2. Replies: 3
    Last Post: 11-05-2014, 01:11 PM
  3. Replies: 7
    Last Post: 07-23-2014, 06:15 AM
  4. [SOLVED] How to i validate if all the values entered in userform textboxes are valid then execute.
    By amethystfeb in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-01-2013, 12:33 PM
  5. Userform Textboxes showing wrong values?
    By Panic in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-18-2008, 09:43 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1