+ Reply to Thread
Results 1 to 14 of 14

Second Combobox refresh

  1. #1
    Registered User
    Join Date
    03-13-2015
    Location
    boomerang
    MS-Off Ver
    Excel pro
    Posts
    19

    Second Combobox refresh

    Hi I've been playing with an excel sheet that will help me put electrical quotes together using a database of items and costs.
    The only thing I can't get my head around is how to activate the second combobox once the first combobox has been selected.

    So for example:

    If the first combobox is "Hager - Design 10" then the second box should display "Enclosure 4 Module DIN Rail White Steel".
    My problem is the second combobox does not automatically update, only when I click in the box. Does anyone know how to fix this?
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Second Combobox refresh

    Perhaps something like this...

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    03-13-2015
    Location
    boomerang
    MS-Off Ver
    Excel pro
    Posts
    19

    Re: Second Combobox refresh

    Cheers for the reply, don't think that does the trick.
    It changes the second "combobox2" but it does not actiavte the box and when I click it the value goes blank?

    If I put:

    Please Login or Register  to view this content.
    That is what I'm after, the only problem with this is that the dynamic named range is not updated

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Second Combobox refresh

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-13-2015
    Location
    boomerang
    MS-Off Ver
    Excel pro
    Posts
    19

    Re: Second Combobox refresh

    That's the one! Thanks for that

  6. #6
    Registered User
    Join Date
    03-13-2015
    Location
    boomerang
    MS-Off Ver
    Excel pro
    Posts
    19

    Re: Second Combobox refresh

    One other thing if you'd be so nice. When I press the button it adds the value to the spreadsheet, which is what I'm after.
    The only problem is I have to click in column D first and then click the button so it is inserted correctly. Any ideas how I could achieve it? So I can click in any column along the row and it will insert correct?

  7. #7
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Second Combobox refresh

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    03-13-2015
    Location
    boomerang
    MS-Off Ver
    Excel pro
    Posts
    19

    Re: Second Combobox refresh

    Nearly. Only problem is when I select anything in the second list "combobox2" it just resets to the first value. I've uploaded the latest file
    Attached Files Attached Files

  9. #9
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Second Combobox refresh

    I have and older version of excel which doesn't work with the newer version of controls (comboboxes). So I can't actually use your workbook. I can see it, but I can't use the comboboxes.

  10. #10
    Registered User
    Join Date
    03-13-2015
    Location
    boomerang
    MS-Off Ver
    Excel pro
    Posts
    19

    Re: Second Combobox refresh

    Ah right OK. Well for some reason when I select anything from the second combobox, say item3, when I click it the combobbox looks like it resets and goes to item 1 again

  11. #11
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Second Combobox refresh

    I don't see anything that could cause that. Sorry.

    As a test, comment out this line to see if somehow this procedure is unexpectedly triggered and resetting Combobox2.

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    03-13-2015
    Location
    boomerang
    MS-Off Ver
    Excel pro
    Posts
    19

    Re: Second Combobox refresh

    I changed the code to this to see whats being called:

    Please Login or Register  to view this content.
    For some reason when I select from the second combobox, message box 2 pops up (which is whats expected) then message box 1 appears and then message box 2 again. This is why I think it resets the combobox. Any ideas why it does this? If that makes sense?

    If you're lost I'll just remove .ListIndex = 0 from the code and leave it at that
    Last edited by walters123; 03-03-2016 at 06:43 PM.

  13. #13
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Second Combobox refresh

    I have no idea why a Combobox1_Change event would get triggered when Combobox2 is changed.

    This code will check if the value of Combobox1 changed from the last time it was triggered. It's a kludge, but it should prevent resetting Combobox2 unless the selected value in Combobox1 changes.

    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    03-13-2015
    Location
    boomerang
    MS-Off Ver
    Excel pro
    Posts
    19

    Re: Second Combobox refresh

    Sorry for the late reply. That works a treat. Thanks again you've been a massive help!

+ 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] Need to Refresh Label in Userform after choosing an Item in a Combobox
    By sdemps in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-18-2013, 11:06 AM
  2. [SOLVED] Need a way to refresh combobox values when new data is submitted.
    By egavasrg in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-04-2012, 03:46 PM
  3. [SOLVED] Refresh Userform ComboBox Data Source
    By lday75 in forum Excel General
    Replies: 1
    Last Post: 08-23-2012, 01:23 PM
  4. Refresh UserForm to display data that is linked to combobox selection
    By alter54 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-16-2012, 01:30 PM
  5. [SOLVED] Using VBA to change a pivot table filter, refresh the report and set up a refresh delay
    By Bonnister in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-18-2012, 10:43 AM
  6. Enable Auto Refresh - Wait for refresh to sinish before running a macro
    By tomlancaster in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-21-2011, 11:52 AM
  7. Refresh Combobox to reflect new data
    By punter1000 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-14-2011, 01:10 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