+ Reply to Thread
Results 1 to 6 of 6

VBA not updating the dropdown list after sheets added.

  1. #1
    Registered User
    Join Date
    11-07-2013
    Location
    Derbyshire, England
    MS-Off Ver
    Excel 2016
    Posts
    52

    VBA not updating the dropdown list after sheets added.

    The code below was written for me a long time ago and I thought it was fine. It was designed to create a list of all the worksheets in the workbook in Drop Down 1 and then enable you to select the one you want and quickly go to it. What I have noticed is that it is not updating the list when I add new worksheets. I'm not good at VBA though I do try to understand when it doesn't work. It seems to me as though the initialize section is wrong but I don't know how.

    Please help.


    Please Login or Register  to view this content.

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: VBA not updating the dropdown list after sheets added.

    I'd consider moving the initialize to the workbook level, and triggering it off of Workbook_NewSheet so that each new sheet that's added triggers an update to the list.

    Please Login or Register  to view this content.
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  3. #3
    Registered User
    Join Date
    11-07-2013
    Location
    Derbyshire, England
    MS-Off Ver
    Excel 2016
    Posts
    52

    Re: VBA not updating the dropdown list after sheets added.

    Quote Originally Posted by daffodil11 View Post
    I'd consider moving the initialize to the workbook level, and triggering it off of Workbook_NewSheet so that each new sheet that's added triggers an update to the list.

    Please Login or Register  to view this content.
    Hi daffodil11,

    I'm sorry but that doesn't seem to work. I've attached the file to see if that helps, I may not have put your code in the correct place.

  4. #4
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: VBA not updating the dropdown list after sheets added.

    I see the issue:

    You missed a letter in the copy and paste, and it's also in the wrong area.

    Workbook-level code should be in the ThisWorkbook object.

    I also added another block on the Sheet10(Select Type) object that will update when that tab is selected. This way the code will also run if you leave that tab to delete another.

  5. #5
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: VBA not updating the dropdown list after sheets added.

    Further to daffodil11 post,

    here's another alternative, which is triggered when activating the sheet (put in the sheetmodule for "Select Type").
    Please Login or Register  to view this content.
    You can then rename and delete sheets, etc., and the drop down will be recalculated when reactivating the sheet. As it's triggered directly in the Select Type sheet and the activeworkbook, no need to clarify a variable for that sheet or to refer to it as thisworkbook.

    Rgs,
    berlan

    EDIT: didn't see daffodil11's new post suggesting the very same approach before posting.
    Last edited by berlan; 02-24-2015 at 02:45 PM.

  6. #6
    Registered User
    Join Date
    11-07-2013
    Location
    Derbyshire, England
    MS-Off Ver
    Excel 2016
    Posts
    52

    Re: VBA not updating the dropdown list after sheets added.

    daffodil11, berlan.

    Thank you both very much.

+ 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. Hyperlink sheets dropdown list
    By okelly in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-16-2013, 05:58 AM
  2. [SOLVED] Macro to Unhide sheets from a Dropdown List
    By JO505 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-19-2013, 05:32 PM
  3. Updating a Sheet when New Sheets are Added
    By DataVanMan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-15-2012, 05:28 AM
  4. Retrieve Data from other sheets using dropdown list.
    By lemuel in forum Excel General
    Replies: 8
    Last Post: 09-28-2012, 09:35 AM
  5. [SOLVED] Updating a dropdown list from SQL server
    By DevalilaJohn in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-28-2006, 04:15 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