+ Reply to Thread
Results 1 to 9 of 9

Display Charts in a UserForm based on Combo Box Selection

  1. #1
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Display Charts in a UserForm based on Combo Box Selection

    I am trying to work out how to display a chart in a UserForm, based on the user selection from a Combo Box. I have looked at the John Walkenbach solution, but have been unable to successfully adapt this to meet my needs.

    I have attached a simple sample file to demonstrate what I am trying to achieve. I have a UserForm with an Image Control, a Combo Box, a Text Box and a Close Button.

    I have three charts and what I want to be able to achieve is for the user to select an option from the dropdown menu and for the appropriate chart to be displayed in the Image Control and for the Text from the Combo Box to be displayed in the Text Box above the chart.

    I have got as far as being able to display the 'first' chart in the Image Control, but it displays the same chart irrespective of which option I select from the Combo Box and I have no idea how to display the relevant text in the Text Box. I would like to have the first chart already displayed in the Image Control when the user launches the UserForm.

    I am no expert when it comes to VBA, so if anyone is able to help, with simple step by step instructions indicating which code goes where that would be gratefully appreciated, so I can try to understand the logic.
    Attached Files Attached Files
    Last edited by HangMan; 07-12-2011 at 07:57 AM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Display Charts in a UserForm based on Combo Box Selection

    You are not changing the chart number argument in the combo change event

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Display Charts in a UserForm based on Combo Box Selection

    Hi Andy

    OK, that makes sense and works. Many thanks...

    How would I go about displaying the first chart in the list by default when the UserForm is launched, rather than the Image Cntrol being blank and how can I then display the text from the Combo Box in the Text Field?

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Display Charts in a UserForm based on Combo Box Selection

    Set the value of the combobox to the 1st item.

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Display Charts in a UserForm based on Combo Box Selection

    Easy when you know how... As you can tell I'm learning!

    Any thoughts on the final part, how to then display the text from the ComboBox in the Text Field above the chart?

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Display Charts in a UserForm based on Combo Box Selection

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Display Charts in a UserForm based on Combo Box Selection

    Andy

    Thank you so much, I have spent the last two days trying to figure out how to do this and you have solved my problem in 5 minutes. I guess knowledge goes a long way...

    I really appreciate your help - I think I need to find a good VBA book to read...

  8. #8
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Display Charts in a UserForm based on Combo Box Selection

    Andy

    Sorry to bother you again... Let me know if it is inappropriate to post and if I need to post this as a seperate topic

    One additional thing, slightly off topic, but how can I rescale the graphs to fill the Image Control? If I rescale the 3 graphs and then view them in the UserForm, they automatically revert back to their original size?

  9. #9
    Registered User
    Join Date
    05-25-2016
    Location
    Erlanger, KY
    MS-Off Ver
    2010
    Posts
    81

    Re: Display Charts in a UserForm based on Combo Box Selection

    Not sure If I need to start another posts, or If I can ask questions on this one. I have a similar situation, except it is not a user form it is a dashboard and there are no buttons and all of the charts are on another sheet within the workbook? Not sure how I can modify this code to give me what I need. I tried another code that I had found through google and it is not working for me either. I only have today to get this done, any help would be appreciated. I have looked and cannot find an area where I can upload the file. PLEASE HELP!

+ 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