+ Reply to Thread
Results 1 to 4 of 4

Combobox Number As Variable

Hybrid View

  1. #1
    Registered User
    Join Date
    01-29-2012
    Location
    United Kingdom
    MS-Off Ver
    MS Office 2003/MS Office 2010
    Posts
    45

    Combobox Number As Variable

    Hi, there!

    I have a following problem i need to solve:
    Let's say i have a form with 16 Comboboxes.

    I have a function to find unique values, sort them ascending and fill in combobox. So, i would like to find out how could i send Combobox number as parameter?

    The code so far is:

    Private Sub CommandButton1_Click() 
        Dim FormCombo As Object 
        Dim Comb As Object 
         
         
        Set FormCombo = AddData.LineNumber 
        Call Sort_Combo_AZ(Sheets("ProductShot").Range("A4:A60000"), FormCombo) 
        AddData.CheckBox1.Value = True 
         
         
        Set FormCombo = AddData.ProductCode 
        Call Sort_Combo_AZ2(Sheets("ProductShot").Range("B4:B60000"), FormCombo) 
         
        For i = 1 To 16 
            Set FormCombo = AddData.ComboBox & i ' this is the part that doesn't work
            Call Sort_Combo_AZ(Sheets("ProductShot").Range("D4:D60000,F4:F60000"), FormCombo) 
             
        Next i 
         
         
        StartUp.Hide 
        AddData.Show 
         
    End Sub 
     
    Function Sort_Combo_AZ(AllCells1 As Range, FormCombo As Object) 
    [some code]
    End function
    Thanks for your help!
    Last edited by trenars; 01-30-2012 at 04:34 AM.

  2. #2
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Combobox Number As Variable

    Hi,
    You can use
     Set FormCombo = AddData.Controls("ComboBox" & i)
    Good luck.

  3. #3
    Registered User
    Join Date
    01-29-2012
    Location
    United Kingdom
    MS-Off Ver
    MS Office 2003/MS Office 2010
    Posts
    45

    Re: Combobox Number As Variable

    This is what i was looking for! Great work! Thanks!

  4. #4
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Combobox Number As Variable

    My pleasure. Please do not forget to mark the thread solved (See FAQ link at top of the page for instructions)

+ 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