+ Reply to Thread
Results 1 to 4 of 4

Forcing RowSource in ComboBox to increase

  1. #1
    Registered User
    Join Date
    03-13-2008
    Posts
    52

    Forcing RowSource in ComboBox to increase

    Please Login or Register  to view this content.
    I have the above code to add a new 'consultant' to an existing list should the user wish to do so. I've tried to set the code to automatically increase the size of the RowSource currently being used in VBA (which at the moment is set as C1:C10) however it just doesn't work.

    I've tried setting the RowSource manually with VBA code however it doesn't seem to work for me so I've had to use the properties window. Does anyone know a way of forcing VBA to change a value set in itself (if a new consultant was added now it should automatically change the RowSource to C1:C11, then C1:C12 for the next one etc)?

    Many thanks in advance for anyones help.

    ~Liam

  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,258
    Hello Liam,

    It would help to know if you are getting errors messages when the code runs, and which ones. If your UserForm isn't loaded, you can't access any of the controls on it. I suspect this maybe the case.

    Sincerely,
    Leith Ross

  3. #3
    Valued Forum Contributor
    Join Date
    08-26-2006
    Location
    -
    MS-Off Ver
    2010
    Posts
    388
    Quote Originally Posted by LiamPotter

    I have the above code to add a new 'consultant' to an existing list should the user wish to do so. I've tried to set the code to automatically increase the size of the RowSource currently being used in VBA (which at the moment is set as C1:C10) however it just doesn't work.

    I've tried setting the RowSource manually with VBA code however it doesn't seem to work for me so I've had to use the properties window. Does anyone know a way of forcing VBA to change a value set in itself (if a new consultant was added now it should automatically change the RowSource to C1:C11, then C1:C12 for the next one etc)?

    Many thanks in advance for anyones help.

    ~Liam
    Google Excel dynamic named ranges.

    If you create a named range called ConsultantList and set its refers to value to

    =OFFSET(Sheet1!$C$1,0,0,COUNTA(Sheet1!$C:$C),1)

    the range becomes dynamic and you can use the ConsultantList name as the RowSource property in the ComboBox.

    When you add a new consultant to the list the range automatically grows and no further code is required, except to sort the list.

    I have some code if you need any more help.

  4. #4
    Registered User
    Join Date
    03-13-2008
    Posts
    52
    I've never used dynamic ranges before however doing as you have mentioned has worked perfectly.

    Upon testing once by adding and removing the consultant XXX, the ListBox doesn't shrink again and leaves a blank entry behind. I've managed to come around this by simply adding the following code:

    Please Login or Register  to view this content.
    Many thanks for your response, has worked perfectly!

    ~Liam

+ 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