+ Reply to Thread
Results 1 to 7 of 7

combobox dynamic rowsource

Hybrid View

  1. #1
    Registered User
    Join Date
    11-12-2012
    Location
    Michigan
    MS-Off Ver
    Excel 2010
    Posts
    48

    combobox dynamic rowsource

    Currently I have a book that has a combobox inside a usermodule.

    The row source is set to Sheet1!E2:E12

    E2:E12 all have values in them...

    Let's say I add something to E13.. How can I get the rowsource to automatically include E13 without me having to manually update it every time?

  2. #2
    Registered User
    Join Date
    05-21-2012
    Location
    Bangalore
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: combobox dynamic rowsource

    Hello,

    Go to 'Name Manager' in 'Formulas' tab. Create new: Set Name exa. "List" then copy below code in "Refers to:"
    =OFFSET(Sheet1!$E$2, 0, 0, COUNTA(Sheet1!$E:$E)-1,1)
    Then goto your userform, select the combobox, set "=List" in 'RowSource' property.

    That's it.

  3. #3
    Forum Contributor
    Join Date
    03-14-2012
    Location
    location
    MS-Off Ver
    Excel 2007
    Posts
    170

    Re: combobox dynamic rowsource

    or in your UserForm
    Private Sub UserForm_Initialize()
    
        Dim lRow As Long
        lRow = Sheets(1).Range("e53556").End(xlUp).Row
        Me.ComboBox1.List = Sheets(1).Range("e1:e" & lRow).Value
    
    End Sub
    blue

  4. #4
    Registered User
    Join Date
    11-12-2012
    Location
    Michigan
    MS-Off Ver
    Excel 2010
    Posts
    48

    Re: combobox dynamic rowsource

    Blue, I'll give that a little jot in my notebook and try that also. Never a bad thing to know how to do something multiple ways. Thanks!

  5. #5
    Registered User
    Join Date
    11-12-2012
    Location
    Michigan
    MS-Off Ver
    Excel 2010
    Posts
    48

    Re: combobox dynamic rowsource

    I had to change

    =OFFSET(Sheet1!$E$2, 0, 0, COUNTA(Sheet1!$E:$E)-1,1
    to

    =OFFSET(Sheet1!$E$2, 0, 0, COUNTA(Sheet1!$E:$E)+1,1)
    Because with the -1 near the end, it took the last one of the list out. So if I had the list 1,2,3,4,5... The -1 only made it show 1,2,3,4... But either way, it worked well enough for me Thank you!

  6. #6
    Registered User
    Join Date
    05-21-2012
    Location
    Bangalore
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: combobox dynamic rowsource

    Good !

    You can set this tread as [Solved].

  7. #7
    Forum Contributor
    Join Date
    03-14-2012
    Location
    location
    MS-Off Ver
    Excel 2007
    Posts
    170

    Re: combobox dynamic rowsource

    Hello rybussell,

    thx for the feedback!

+ 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. [SOLVED] Add RowSource to Userform ComboBox based on value on Another ComboBox
    By Baziwan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-10-2012, 01:17 PM
  2. Way to populate combobox rowsource based on previous combobox value
    By subbby in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-08-2012, 12:50 AM
  3. Combobox: How to determine the location of the selected item if combobox has rowsource
    By ahsanzafar in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-11-2012, 03:24 PM
  4. Combobox Rowsource Dynamic Range
    By roy__lam in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-06-2012, 09:44 AM
  5. [SOLVED] How do I set the rowsource for a ComboBox for a dynamic list?
    By ndm berry in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-29-2005, 09:05 AM

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