Consulting

Results 1 to 11 of 11

Thread: Solved: Graph populated by Dropdown

  1. #1
    VBAX Mentor Hoopsah's Avatar
    Joined
    Nov 2007
    Posts
    303
    Location

    Solved: Graph populated by Dropdown

    Hi

    does anyone know ho to create a graph that changes its details depending on the choice made from a dropdown menu

    I have a series of data and I want to let the user choose a specific region and a specific day of the week from dropdown menus and the graph reflects this choice

    Thanks for any help

    Hoopsah

    I am playing all the right notes, but not necessarily in the right order.
    Eric Morecambe

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Can you post a sample data file and typical graph?
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Mentor Hoopsah's Avatar
    Joined
    Nov 2007
    Posts
    303
    Location
    Hi MD

    I have attached a copy of the sort of data that we have. I am hoping to get just a standard bar graph showing a count total.

    I would like to have 2 dropdowns asking: Month & Regions and only show the details for those. Along the bottom I would like: Mondays, Tuesdays etc. and the user can then pick February & Ness and it would show the details for all the Standard connections made on a monday next to all the non-standards etc.

    Hope this is clear - I am still at the headscratching stage at the moment

    Cheers MD

    Gerry
    I am playing all the right notes, but not necessarily in the right order.
    Eric Morecambe

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Gerry
    I can't see where the Months come into this.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    VBAX Mentor Hoopsah's Avatar
    Joined
    Nov 2007
    Posts
    303
    Location
    Ooops!

    Sorry I just cut and pasted some data - I have attached the actual sheet this time.

    Cheers
    I am playing all the right notes, but not necessarily in the right order.
    Eric Morecambe

  6. #6
    VBAX Tutor
    Joined
    Oct 2007
    Posts
    210
    Location
    If the data could be stored on a seperate tab for each selected item then this code will work.

    [vba]prmSelection = Range("B2").Value + 1
    ActiveSheet.ChartObjects("chartLastTen").Activate
    ActiveChart.SetSourceData Source:=Sheets(prmSelection).Range("B1:B11")
    ActiveChart.SeriesCollection(1).XValues = Sheets(prmSelection).Range("A2:A11")

    [/vba]
    prmSelection is based on the selection in a combo box that is on the first sheet (interface) and adds one to make the second sheet the first data sheet. "ChartLastTen" is my named chart on the first (interface) sheet. Since the data is uniform, the code simply references the correct sheet.
    If the format you have has to be that way. I would still put each group on a seperate tab and create another sheet linked to this data for your report.
    "The amount of stupid people in the world is God's way of punishing the smart people" - protean_being

  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Gerry,

    It would be better if you could re-structure the data, like this perhaps
    February Monday Ness Std Connection 7
    February Monday Ness Non Std Connection 1
    February Monday Ness Sewer Connection 1
    February Monday Ness Water Facilitation 3
    February Monday Ness Sewer Facilitation 0
    February Monday Don Std Connection 7
    February Monday Don Non Std Connection 0
    February Monday Don Sewer Connection 2
    February Monday Don Water Facilitation 1
    February Monday Don Sewer Facilitation 0
    ...
    ...
    February Tuesday Ness Std Connection 3
    February Tuesday Ness Non Std Connection 0
    February Tuesday Ness Sewer Connection 6
    February Tuesday Ness Water Facilitation 3
    February Tuesday Ness Sewer Facilitation 4
    ...
    ...
    March Monday Ness Std Connection 1
    March Monday Ness Non Std Connection 2
    March Monday Ness Sewer Connection 3
    March Monday Ness Water Facilitation 4
    March Monday Ness Sewer Facilitation 5

    it will make it simpler to build the graphs then as we could assign named ranges and use these
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  8. #8
    VBAX Mentor Hoopsah's Avatar
    Joined
    Nov 2007
    Posts
    303
    Location
    Thanks for your input guys.

    I'll away and do a bit more headscratching and either come back and ask again or let you know how I got on

    Cheers again

    Gerry
    I am playing all the right notes, but not necessarily in the right order.
    Eric Morecambe

  9. #9
    VBAX Mentor Hoopsah's Avatar
    Joined
    Nov 2007
    Posts
    303
    Location
    Ok,

    so far I have changed the data layout and created a graph for the Monday only.

    So, anyone know how I would add a dropdown to let the user choose Tuesday, Wednesday.........
    I am playing all the right notes, but not necessarily in the right order.
    Eric Morecambe

  10. #10
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    A simple pivot chart
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  11. #11
    VBAX Mentor Hoopsah's Avatar
    Joined
    Nov 2007
    Posts
    303
    Location


    Aw Man!!

    I'm really sorry Bob, as soon as I read your post "a simple pivot chart" - before I even opened it it dawned on me that it should be a pivot chart.

    You have shown me how to do a proper pivot chart before and believe it or not I actually use it every week.

    Sorry for not realising sooner - but thanks once again for you help

    Take care Bob

    Gerry
    I am playing all the right notes, but not necessarily in the right order.
    Eric Morecambe

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •