+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Forum Contributor
    Join Date
    05-13-2009
    Location
    London, England
    MS-Off Ver
    Excel XP
    Posts
    174

    Creating chart, conditional on cell clicked

    Ok fellas, this is a very complicated one, so I'm searching for a VBA champion.
    I need to make this graph using. All the data to be used is in the sheet 'DataforGrid' under the 2nd Table. Ineed the graph to look like 'Chart B' which I have pasted from another source under the coloured Heatmap. The way it should work is that there will be 2 scroll bars to select 2 dates. Then based on those 2 dates - two lines are graphed one for each date. you can ignore the bar charts on 'chart B'....the 2 lines will have 8 data points (as there are 8 Terms for each product on the heatmap grid, and 8 products for each Term)
    So what data will these 2 lines cover?

    Look at the heatmap - you see Product and Term. Outside the coloured boxes you can see the categories of product and term. Row 4 has product, and Column B has Term.
    What I want to do is be able to click on say cell B7 (which is 1m), when I do this i want to graph the values of (1m in 1y, 1m in 2y, 1m in 5y, 1m in 7y and so on till 1m in 30y)----lets call it horizontal charting. That is 8 values/points on the line, im not charting these entire series but rather, just for the 2 dates that were selected in the scroll bar...this is to show the difference between the values of the term/product on those dates.
    now the same thing needs to be done vertically so if i select a Product 30y....it will chart --1m in 30y, 3m in 30y, 6m in 30y all teh way to 10y in 30, thats 8 points.
    So in total there are 16 different cells that I should be able to click, 8 product, 8 term.


    If we are charting a 'Term' then x-axis will have the 8 products and the chart label will be the 'Term' category-eg. 5Y, Y axis will have the values on that day(ignore the 2nd y-axis on Chart B which has some weird figures


    (****In sheet ' DataforGrid' you will see categories like 3m in 7y, etc the first item is always term, the 2nd is product
    so remember its 'Term in Product')

    I hope I wasnt confusing, if so let me know and I will try to explain better

    any help would be much appreciated, I understand this can be quite difficult so my expectations are not that high

    thanks for reading, and good luck (i need more than just luck here)
    Attached Files Attached Files
    Last edited by Pasha81; 06-13-2009 at 07:38 AM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    2003 & 2007 & 2010
    Posts
    10,944

    Re: Creating chart, conditional on cell clicked

    You do not need VBA to do this.

    You can use Data validation for the selection of Dates, Term/Product, specific term/product.

    Then with the 4 pieces of information you can use formula to locate the required chart labels and data values.
    Attached Files Attached Files
    Cheers
    Andy
    www.andypope.info

  3. #3
    Valued Forum Contributor
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    Posts
    597

    Re: Creating chart, conditional on cell clicked

    Hi there,

    Well, you were right - it was a bit complicated - not too difficult to program, but not all that easy to understand!

    Please take a look at the attached and let me know if I've understood your requirements correctly. The only thing the user has to do is to enter the required dates and then select the required values of Term and Product from the dropdown lists. The graphs will update automatically.

    I'd be glad to have your feedback on this one, even if it's only to let me know that I've completely misunderstood what you had in mind!

    Regards,

    Greg M
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    05-13-2009
    Location
    London, England
    MS-Off Ver
    Excel XP
    Posts
    174

    Re: Creating chart, conditional on cell clicked

    sorry, i know its not easy to understand as i've got 'Years/ time' on both axes...but you guys got it right.
    Excellent work, both of you Greg and Andy! Looks like you guys put some time in for this, definitely does the job and looks organised.
    But do you know by any chance if the dates could be selected with a scrollbar, just that I was asked to do it with scrollbars for ease of use.

    thanks a lot guys...both versions work

  5. #5
    Valued Forum Contributor
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    Posts
    597

    Re: Creating chart, conditional on cell clicked

    Hi again,

    I originally thought about using dropdown lists for the dates, and doing this will avoid the possibility of entering a date for which no data are available. However, the possible disadvantage is that users may have to scroll down through several hundred dates on the list, and this might prove to be more trouble than it's worth.

    It's not a problem to make the dates available from a dropdown list, but are you sure that's the best approach?

    Incidentally, if you're interested, I produced a slightly modified version of the workbook which would allow you to change the layout of your main data worksheet, i.e. to have more/fewer columns before the date column, and more/fewer rows before the title column.

    Please let me know if you want me to implement the date dropdown list or anything else.

    Regards,

    Greg M

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    2003 & 2007 & 2010
    Posts
    10,944

    Re: Creating chart, conditional on cell clicked

    You can use a scrollbar. If you use a scrollbar from the forms toolbar you can link it's value to a cell. This value would then be used as the row index for the available dates.

    The only problem is the Maximum value of the scroll bar can not linked to a cell or formula. So if the number of dates increases you will need to increase the maximum value of your scroll bar.
    You can set the maximum very high and then use formula to cap the maximum value used for the INDEX formula to be that of the maximum date values.
    Cheers
    Andy
    www.andypope.info

  7. #7
    Forum Contributor
    Join Date
    05-13-2009
    Location
    London, England
    MS-Off Ver
    Excel XP
    Posts
    174

    Re: Creating chart, conditional on cell clicked

    thanks guys, i'll just try plugging in a scrollbar, i've tried before and failed i'll give it another shot

  8. #8
    Valued Forum Contributor
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    Posts
    597

    Re: Creating chart, conditional on cell clicked

    Hi again,

    Take a look at the attached workbook and see if the scrollbar does what you want.

    Hope this helps - please let me know how you get on.

    Regards,

    Greg M
    Attached Files Attached Files

  9. #9
    Valued Forum Contributor
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    Posts
    597

    Re: Creating chart, conditional on cell clicked

    Hi again,

    Sorry - try this version instead! It will cope with up to 1000 dates.

    Please let me know how you get on.

    Regards,

    Greg M
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    05-13-2009
    Location
    London, England
    MS-Off Ver
    Excel XP
    Posts
    174

    Re: Creating chart, conditional on cell clicked

    thanks Greg, the scroll bar does work like i wanted, now I'll try plugging it into my sheet, hopefully i can make it work there like you did, i'm surprised there was no vba required at all for the whole charting process

  11. #11
    Valued Forum Contributor
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    Posts
    597

    Re: Creating chart, conditional on cell clicked

    Hi again,

    Thanks for your feedback - I'm glad I was able to help.

    Ok on not needing VBA for the chart updating. I usually find that it's easier to "point" a chart at a specific range and to manipulate the contents of that range, than to try to manipulate the chart itself. As a consequence, the amount of VBA required is often very little, and relates just to updating one or two cells whose values are then used to populate the data range .

    Regards,

    Greg M

  12. #12
    Forum Contributor
    Join Date
    05-13-2009
    Location
    London, England
    MS-Off Ver
    Excel XP
    Posts
    174

    Re: Creating chart, conditional on cell clicked

    I'll mark this solved now, sorry about the delay was travelling last few days.
    You guys did a fantastic job hee, thanks....though I just cant get my scrollbar to work, I'm making some very basic mistake I'm sure, but that's ok. If I run in to any problems while making additions to the model I'll let you know

    thanks again

  13. #13
    Forum Contributor
    Join Date
    05-13-2009
    Location
    London, England
    MS-Off Ver
    Excel XP
    Posts
    174

    Re: Creating chart, conditional on cell clicked

    Hi Greg,

    here's the scrollbar issue, when I tried to link it to the cell 'ptrScrollOffset1' the scrollbar disappeared...

    Oh and another thing, about labelling the chart -- on the current version for Term 1y, see that on the X-axis we have 1y in 1y, 1y in 2y, 1y in 5y etc... is there a way to make that 1y,2y,5y, and so on till 30y on the X-axis, and at the top of the chart it'll say Term 1y.....

    something like that, would make it look more concise, whats the formula for that, do i type it into Chart Title after selecting chart options?


    thanks again buddy
    Attached Files Attached Files

  14. #14
    Valued Forum Contributor
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    Posts
    597

    Re: Creating chart, conditional on cell clicked

    Hi again,

    Ok - I think things started to go wrong for you when you decided to use the Activex scrollbar (from the Control Toolbox toolbar) rather than the one you find on the Forms toolbar. Activex controls are more powerful, but also less user-friendly.

    I've adjusted the x-axis titles on the attached version and hope that I've got them the way you wanted.

    Hope this helps - please let me know how you get on.

    Regards,

    Greg M
    Attached Files Attached Files

  15. #15
    Forum Contributor
    Join Date
    05-13-2009
    Location
    London, England
    MS-Off Ver
    Excel XP
    Posts
    174

    Re: Creating chart, conditional on cell clicked

    thanks Greg..

    i didnt know about the forms scrollbar before, it is way easier for sure, but
    something's wrong I'm getting dates from Jan 2000 to Sep 2002 which is not even in my range so its giving me a blank graph. Am I supposed to hihlight the Dates Range in 'Data' while making thescrollbar?

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.2.0