+ Reply to Thread
Results 1 to 9 of 9

Dynamic combo row source - works only if active source worksheet

  1. #1
    Registered User
    Join Date
    02-21-2010
    Location
    Italy
    MS-Off Ver
    Excel 2013
    Posts
    77

    Dynamic combo row source - works only if active source worksheet

    Hi there,
    I'm here again for another topic which is quite puzzling me up.
    I want to define a row source for a userform's combo but the rows may vary according to new data entered in a given worksheet.

    My source worksheet is named DATI and the cell range that I want to define is in column C:C.
    At first I defined in the userform properties for the combo a row source value like this : DATI!C2:C200 but many rows are still empty and I don't want that.
    Then I defined a function which assigns the row source via code like this
    Please Login or Register  to view this content.
    this code actually works but only if I launch the function with DATI worksheet as the active worksheet..as soon as I launch the function in another worksheet (as I want it to) the function gives the combo a row source of column C referred to the active worksheet

    How can I fix that to point always to my DATI worksheet?

    Thanks in advance for your time
    P.
    Last edited by fredpox; 03-20-2010 at 08:19 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Dynamic combo row source - works only if active source worksheet

    It's an over cpmplicated way to do it. Try
    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    02-21-2010
    Location
    Italy
    MS-Off Ver
    Excel 2013
    Posts
    77

    Re: Dynamic combo row source - works only if active source worksheet

    Hi royUK,
    thanks for your fast reply
    I had a few issues when trying your code and the range was once again referred to an unreferenced worksheet.
    I change it like this and it works great!
    Please Login or Register  to view this content.
    Thanks again for your help!

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Dynamic combo row source - works only if active source worksheet

    Sorry,codeshould be
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-21-2010
    Location
    Italy
    MS-Off Ver
    Excel 2013
    Posts
    77

    Re: Dynamic combo row source - works only if active source worksheet

    thanks again royUK! now the code works fine.
    Just a 'semantic' question: What the .list does exactly here to include also the worksheet selected?

    thank you for all of your time
    P.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Dynamic combo row source - works only if active source worksheet

    It doesn't include the worksheet,the rComboRng is set to the DATI worksheet

  7. #7
    Registered User
    Join Date
    02-21-2010
    Location
    Italy
    MS-Off Ver
    Excel 2013
    Posts
    77

    Re: Dynamic combo row source - works only if active source worksheet

    right but..maybe I wasn't much clear in my question
    when I wrote this with .RowSource property
    Please Login or Register  to view this content.
    if I didn't insert the "DATI!" string, the range would have had a reference to every possible worksheet.
    Your code with .List instead retrieved exactly the range you set with the With clause.
    My question is, what's the difference between .RowSource and .List as a combo property?

    thanks again for your patience
    P.

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Dynamic combo row source - works only if active source worksheet

    Try adding external=True,tolet Excelknow that the RowSource is on a different sheet

    Please Login or Register  to view this content.
    This will show the difference. Rowsource needs the full address,whereas Listuses the Value property of a Range

  9. #9
    Registered User
    Join Date
    02-21-2010
    Location
    Italy
    MS-Off Ver
    Excel 2013
    Posts
    77

    Re: Dynamic combo row source - works only if active source worksheet

    Thanks royUK, that finally makes sense,
    I didn't know about that difference but as soon as you posted your code with the .List property something told me that it may be very useful for the future.
    thank you for helping me figuring it out. :-)

    have a nice day!
    P.

+ 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