+ Reply to Thread
Results 1 to 4 of 4

Control Arrays

Hybrid View

  1. #1
    Registered User
    Join Date
    01-19-2007
    Posts
    24

    Unhappy Control Arrays

    Hello!
    I know that VBA doesn't support control arrays, but I was wondering if anybody out there had found a fairly uncomplicated way of simulating them.
    I have a specific need to have around 120 text boxes on a particular user form and I really don't feel like having to put code in each one since they will be used virtually the same way.
    Can anybody throw me a bone here?

    Thanks.
    Greg.

  2. #2
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi,

    Do you mean something like ...
    Private Sub CommandOK_Click()
    Dim i As Long
    For i = 1 To 120
    Sheets("Data").Range("A" & i) = Me.Controls("TextBox" & i).Value
    Next i
    Unload Me
    End Sub
    HTH
    Carim


    Top Excel Links

  3. #3
    Registered User
    Join Date
    01-19-2007
    Posts
    24
    Thanks. Great idea. I didn't realize you could use the controls collection like that.
    Basically, I need to update a spreadsheet based on what is entered in a user-form. The user form is quite complex, basically a data entry form, with multiple tabbed pages, etc.
    So, as long as I name the related text boxes with something simular and then a number (i.e. monthly1 - monthly10), I should be able to iterate through the correct boxes and update the appropriate spreadsheet row/column.
    Sounds doable. Thanks.

    However, there is no "update" button. Whatever the user enters it automatically sent to the sheet. What event would you use to trap this?

  4. #4
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    As in the example a command button with OK caption for user to click on ...

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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