+ Reply to Thread
Results 1 to 10 of 10

fill listbox (ActiveX) based combobox (ActiveX)

Hybrid View

  1. #1
    Registered User
    Join Date
    09-29-2014
    Location
    brasil
    MS-Off Ver
    ms office 2010
    Posts
    56

    fill listbox (ActiveX) based combobox (ActiveX)

    how fill listbox (ActiveX) based combobox (ActiveX)
    Private Sub ComboBox1_Change()
    
    Dim c As Variant
    
        With Worksheets("Dados")
            c = Application.Match(ComboBox1.Value, .Range("A1:D1000"), 0)
        
            If Not IsError(c) Then
                ListBox1.List = .Range(.Cells(2, c), .Cells(Rows.Count, c).End(xlUp)).Value
            End If
        End With
    
    End Sub
    i need choise value in combobox (ActiveX), then listbox (ActiveX) show data from tab "OrigData"
    Attached Files Attached Files

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: fill listbox (ActiveX) based combobox (ActiveX)

    Hello elsg,

    You have password protected your workbook. You need to either post the password or a copy of the workbook with the protection removed.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    09-29-2014
    Location
    brasil
    MS-Off Ver
    ms office 2010
    Posts
    56

    Re: fill listbox (ActiveX) based combobox (ActiveX)

    sorry, i haven't password in file or tab.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: fill listbox (ActiveX) based combobox (ActiveX)

    Put this code in sheet AleVBA's worksheet module.
    Option Explicit
    
    Private Sub ComboBox1_Change()
    Dim idx As Long
    
        idx = Me.ComboBox1.ListIndex
        
        If idx <> -1 Then
            Me.ListBox1.List = Sheets("OrigData").Range("A" & (idx + 1) * 2).Resize(2, 13).Value
        End If
        
    End Sub
    
    Private Sub Worksheet_Activate()
        Me.ComboBox1.ListFillRange = ""
        Me.ComboBox1.List = Range("T2:T15").Value
    End Sub
    PS To get started you'll need to activate AleVBA which you can do by selecting the first sheet then going back to AleVBA.
    If posting code please use code tags, see here.

  5. #5
    Registered User
    Join Date
    09-29-2014
    Location
    brasil
    MS-Off Ver
    ms office 2010
    Posts
    56

    Re: fill listbox (ActiveX) based combobox (ActiveX)

    Hi nori my combobox is filled, but my ListBox1 not fill, why happening?

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: fill listbox (ActiveX) based combobox (ActiveX)

    Oops, forgot one more thing, you need to change the no of columns in the listbox.

    Currently that's set to 0, add this to set it to 13.
    Me.ListBox1.ColumnCount = 13
    This is where that code would go.
    Private Sub Worksheet_Activate()
        Me.ComboBox1.ListFillRange = ""
        Me.ComboBox1.List = Range("T2:T15").Value
        Me.ListBox1.ColumnCount = 13
    End Sub

  7. #7
    Registered User
    Join Date
    09-29-2014
    Location
    brasil
    MS-Off Ver
    ms office 2010
    Posts
    56

    Re: fill listbox (ActiveX) based combobox (ActiveX)

    i have othe question.
    how autosize columns?
    my format time in tab nos display same in columns(B,F,J) inside listbox.
    how to correct this format hours in the listbox?

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: fill listbox (ActiveX) based combobox (ActiveX)

    I'm afraid there's no autosize for columns in a listbox, you'll need to set the column widths yourself either in design mode or with code.

  9. #9
    Registered User
    Join Date
    09-29-2014
    Location
    brasil
    MS-Off Ver
    ms office 2010
    Posts
    56

    Re: fill listbox (ActiveX) based combobox (ActiveX)

    ok, but how i format tima (hh:mm) in columns(B,F,J) inside listbox?

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: fill listbox (ActiveX) based combobox (ActiveX)

    You'll need code for that, can't post anything specific right now but it would look something like this.
    For I = 0 To Me.Listbox1.ListCount - 1
        With Me.Listbox1 
             .List(I, 1) = Format(.List(I, 1), "hh:mm")
             .List(I, 5) = Format(.List(I, 5), "hh:mm")
             .List(I, 8) = Format(.List(I, 8), "hh:mm") 
        End With
    Next I

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. combobox activex fill
    By brucemc777 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-17-2014, 11:15 PM
  2. Change a combobox (activex control) based on another cell?
    By shiftyspina in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-11-2013, 11:32 AM
  3. How to fill an activex combobox with a data validation list?
    By Sape in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-03-2013, 04:45 PM
  4. [SOLVED] limits of what you can and cannot fill a listfillrange with for ActiveX-Control Listbox
    By cmore in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-22-2013, 10:49 AM
  5. ActiveX ComboBox: Almost there!!!
    By akexcel in forum Excel General
    Replies: 2
    Last Post: 10-23-2006, 01:09 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