+ Reply to Thread
Results 1 to 19 of 19

Interactive Start Date with a Graph

  1. #1
    Registered User
    Join Date
    05-10-2010
    Location
    Montabaur, Germany
    MS-Off Ver
    Excel 2003
    Posts
    9

    Interactive Start Date with a Graph

    Hi,
    I need help getting started with a makro that I am not sure even exists. I would like to have a graph with interactive start and end points. This means I have data on economic growth and the user wants the graph to start in 2003 and end in 2009. In Sheet 1, I have the data beginning in 1970 and updating automatically from a separate server. In Sheet 2 I have a commandbutton that when pushed opens a new sheet with a graph from 1970 to 2010. I would instead want an input/message box to ask the user when they would like the graph to start and after they fill it in and press ok, the graph is created from 2003 to 2010. Can anyone help me with this? Any info would be highly appreciated.
    Last edited by lmj4; 05-21-2010 at 06:08 AM.

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Interactive Start Date with a Graph

    Hallo in die Eifel!! <wink> (endlich mal jemand aus der Nähe der Heimat).

    Attached is a sample dynamic chart for you to play with. Find all the principles of this explained here:
    http://peltiertech.com/Excel/Charts/Dynamics.html

    Tschö!
    Attached Files Attached Files

  3. #3
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Interactive Start Date with a Graph

    You don't need VBA to make the chart dynamic and interactive. It is simpler to opt for using a couple of input cells clearly identified as date inputs.

    See this link for help on Creating Dynamic and Interactive Charts
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  4. #4
    Registered User
    Join Date
    05-10-2010
    Location
    Montabaur, Germany
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Interactive Start Date with a Graph

    Hi, Thank you for the help. I have learned a lot actually regarding charts that update by themselves. I unfotunately have the problem that the data and the chart are not on the same page. For example I have data in columns "A" through "I." The chart opens in a new sheet once the user clicks on a command button for the chart they need. Is it possible to set the range using an input box that opens once you click on the command button in Sheet 2 that asks for the start and end date? I know from the website that it is possible when everything is in one sheet but i am unsure if this also works when the command button is located in a separate sheet. Thanks again for any help offered.

  5. #5
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Interactive Start Date with a Graph

    Hello lmj4,

    there's no need for the data to be on the same sheet as the chart, especially when you use range names to define the chart. In my previously uploaded file, the chart ranges are set dynamically, based on the values selected manually in two cells. You can of course use an InputBox to ask the user about the start and end date and then write that value into the fields. This will cause the dynamic ranges to recalculate, and you can then assign the range names to the chart series with code along the lines of:

    Please Login or Register  to view this content.
    If you need more help with this, you can post the workbook.

    cheers

  6. #6
    Registered User
    Join Date
    05-10-2010
    Location
    Montabaur, Germany
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Interactive Start Date with a Graph

    Hi
    I have attached the file, as I have still not been able to solve this. My problem is really that I am unsure how to combine the range "drawrange" with the result from the input box. I dont think the dynamic range names will help me in this instance because the file with the data in question is much larger, meaning the data goes from colum a to colum bj. Therefore, I use drawstring. Again, any help would be wonderful.
    Attached Files Attached Files

  7. #7
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Interactive Start Date with a Graph

    lmj4,

    I'm no VBA buff, so what I can offer is only a suggestion.

    Attached, I have created a few formulas and range names in the "Daten" Sheet.

    There is a data validation box to ask for the start date.
    There is a data validation box to ask for the end date.
    There is a cell that calculates the number of rows to be included in the graph from the difference between start and end date.

    I have defined a range name that takes the start date and the number of rows to calculate a dynamic range ( data1Range).

    If I knew how to do it in VBA, I'd go this way:

    create a form with a combo box, asking for the start date. The combo box values come from the populated date cells in the respective column.

    On the same form, have a combo box asking for the end date. The combo box values are the same as the first combo box.

    Calculate the row numbers between the "start" combo box value and the "end" combo box value. (find the location of the start date in the sheet, find the location of the end date in the sheet and subtract the location of the start date. add 1)

    Now you have the parameters to define a range. Starting from Row 3, find the Start date and add the row numbers to define the total range to be included in the chart.

    Write these values into variables and use these variables to construct the DrawString/DrawRange string.

    I notice you have created a function to calculate column letters from numbers. You don't need column letters to address a cell. You can use the VBA Cells() property.

    Cells(3, 1) is A3

    The values in the brackets are Row, Column

    Range(Cells(5, 3), Cells(10, 9)) is C5:I10

    That may make your life easier when constructing the ranges.

    I'm just taking my own baby steps in VBA and can't advise you on a whole solution, but maybe with these pointers, you can get a step closer to your solution.

    cheers,

    PS. Wenn's Dich mal nach Simmerath-Witzerath verschlägt, dann grüss meinen Bruder. Seine Pänz gehen/gingen in Monschau zur Schule.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    05-10-2010
    Location
    Montabaur, Germany
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Interactive Start Date with a Graph

    first off, thanks for the suggestions. They helped me understand the ranges better and I think that is the correct way to go about it as well. The link I am still missing with the whole thing is really how to get the graph to change when you change the range in the data sheet, also without the combo box.

  9. #9
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Interactive Start Date with a Graph

    If you use a dynamic range to define the chart series, then you only have to change the parameters for the dynamic range and the chart will update. You can use an InputBox or ComboBox to ask the user for start and end date. Store these values in a cell and let the dynamic range reference these cells. Have another look at my first attachment. The parameters for the dynamic range are defined in cell G3 (range name = start) and cell G5 (range name = span).

    The dynamic range is defined with this formula for the labels

    =OFFSET(Sheet1!$B$1:$B$42,MATCH(Sheet1!start,Sheet1!$B$2:$B$42,0),0,span,1)

    and an offset from that range for the values. Whenever the values in G3 and/or G5 change, the range name will update, and so will the chart.

  10. #10
    Registered User
    Join Date
    05-10-2010
    Location
    Montabaur, Germany
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Interactive Start Date with a Graph

    Hi Everyone,
    I know the process I want to use to complete this project but I am still unfortunately having an awful time with the named ranges. My new question is that after inserting a new row before the data starts and then putting the start and end date in row a3 and b3, I want to change the VBA code Drawstring, so that it doesnt count the rows and instead will take the named ranges in a3 and b3. For the data in columns c and d, I will have a second named range and so on. Is there a way to make the charts take the ranges based on what is in a3 and b3, rather then the name of the range? Thank you.
    Last edited by lmj4; 05-18-2010 at 10:10 AM.

  11. #11
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Interactive Start Date with a Graph

    I'm not sure I follow.
    putting the start and end date in row a3 and b3
    and
    instead will take the named ranges in a3 and b3.
    is contradictory.

    Do A3 and B3 have dates or named ranges?

  12. #12
    Registered User
    Join Date
    05-10-2010
    Location
    Montabaur, Germany
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Interactive Start Date with a Graph

    Hi Teylyn,
    Sorry about the confusion. From Copy of Excel Help; My J5 is a3 and and my J7 is b3. I moved them there because the data have different start dates and so I have to make multiple dynamic ranges. One example is that data3 starts at 31.3.2008 instead of 31.1.2008, so I cant just have one dynamic range (at least that was my understanding).

    Grüß
    lmj4

  13. #13
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Interactive Start Date with a Graph

    Sorry, you've lost me.

    Can you produce a smaller sample file that illustrates the problem? I'm not too keen on downloading half a MB to get to the root of this.

  14. #14
    Registered User
    Join Date
    05-10-2010
    Location
    Montabaur, Germany
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Interactive Start Date with a Graph

    Hi, okay, I took away the page with checkboxes. I have inserted 2 new rows before the data starts and then copied the named ranges, that were previously to the right of the data. I want to create named ranges for the data refering to columns c and d, as well as refering to e and f. That is no problem. However, once I have the named ranges, there is no way for Drawstring to recognise them without stating each Name. Therfore, I wanted Drawstring to recognise that a3 is Data1Range and then go on to data2 and recognise that the next name is c3 and then go to the data 3 and recognise that the name is e3. Is that clearer now?
    Attached Files Attached Files
    Last edited by lmj4; 05-19-2010 at 09:32 AM.

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

    Re: Interactive Start Date with a Graph

    Your code in the latest example will not run so it's hard to test.

    This will plot the information in columns A:B based on the date selection in A3 and B3

    CHT_DATE1: =OFFSET(Daten!$A$4,MATCH(Daten!$A$3,data1list,0),0,MATCH(Daten!$B$3,data1list,0)-MATCH(Daten!$A$3,data1list,0)+1,1)

    CHT_DATA1: =OFFSET(CHT_DATE1,0,1)


    Set the Category range to reference CHT_DATE1 and the Values to CHT_DATA1. So your series formula would look like
    =SERIES(,'smaill_ excel_help.xls'!CHT_DATE1,'smaill_ excel_help.xls'!CHT_DATA1,1)


    You can create another named range for data in column D.

    CHT_DATA2: =OFFSET(CHT_DATE1,0,3)

    For the information in columns E:F you will need to create a new named ranges

    CHT_DATE3: =OFFSET(Daten!$E$4,MATCH(Daten!$A$3,Daten!$E$5:$E$29,0),0,MATCH(Daten!$B$3,Daten!$E$5:$E$29,0)-MATCH(Daten!$A$3,Daten!$E$5:$E$29,0)+1,1)
    CHT_DATA3: =OFFSET(CHT_DATE3,0,1)
    Cheers
    Andy
    www.andypope.info

  16. #16
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Interactive Start Date with a Graph

    Thanks, Andy!

  17. #17
    Registered User
    Join Date
    05-10-2010
    Location
    Montabaur, Germany
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Interactive Start Date with a Graph

    Hi Andy,
    Thank you! I thought that is also how to do that. If you have a look at my first excel_help.xls file, you will notice a start page with checkboxes on it. When a user clicks on a checkbox, a graph opens in a new worksheet. I created a macro called drawstring which draws the range of the graph. The spreadsheet works in that, you click on the clickbox for a graph to appear in a new sheet. The range is stipulated in a macro located in Sheet Daten. Once the range is found it says to use the Macro named Zeichen1,(found in Modul Graph), which is simply the formating for the graph.

    I changed Drawstring so that it says

    Zeilenanzahl = Sheets("Daten").Cells(3, Spalte)
    Instead of
    Zeilenanzahl = Sheets("Daten").Cells(Rows.Count, Spalte).End(xlUp).Row
    (Zeilenanzahl means Number of Rows in German)

    My idea was that I would have the named ranges stipulated in a3 and b3 for each pair of data and that Drawstring would then take the range from what is given into a3 and b3. Does that make sense?However, as names are not specific to cells, it doesnt work. Therefore, I am still confused about how to get the named range into the graph.

    Cheers,
    lmj4

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

    Re: Interactive Start Date with a Graph

    This will generate the correct Drawstring references.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  19. #19
    Registered User
    Join Date
    05-10-2010
    Location
    Montabaur, Germany
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Interactive Start Date with a Graph

    Hi Andy and Teylyn,
    Thank you both so much for your help and tips. I have learned a lot through the process and hope that this thread has also helped others. I will also mark it solved.

    Cheers,
    lmj4

+ 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