+ Reply to Thread
Results 1 to 10 of 10

Creating chart in VBA? Chart based on user selected date?

  1. #1
    Forum Contributor
    Join Date
    03-31-2010
    Location
    Norway
    MS-Off Ver
    Excel 365
    Posts
    632

    Creating chart in VBA? Chart based on user selected date?

    Hi all,

    I was hoping I could get some assistance on creating a fairly basic line chart. I considered posting this in the charting section, but it might be that this is better solved using VBA?

    I created an additional sheet just to show a bit better what my problem is. My "raw data" is in a table in column J-O. I tried creating a chart using just this table, but it's a mess.

    In cells C3&4-F3&4 shows how Excel would like to read my data in order to print a line chart with paired data.

    Basically, the first data point is always 0 at 09:30 and the final data point is always at 16:00 with a corresponding price (see table).

    Maybe there is a smarter way to format/set up my data such that I can create charts directly from my tables?

    Chart.png

    Finally, I was thinking that it would be great if I could have the functionality of refreshing/drawing the chart by selecting the corresponding date. I could select the cell with date and then run the macro.

    Chart2.png

    Maybe this is too involved of a task to be asking here for free, but I figured I could ask.

    Thanks in advance for any help!

    Best regards,

    Elijah
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    03-31-2010
    Location
    Norway
    MS-Off Ver
    Excel 365
    Posts
    632

    Re: Creating chart in VBA? Chart based on user selected date?

    Also, there is a weakness with the chart I created since it has only 4 time points with equal distance between them.

    There is 6 1/2 hours from 09:30 and 16:00.

    Between the 2nd and 3rd data point, there's over 5 hours, but it appears to be the same as between the 3rd and the 4th which have only 2 minutes...

    I tried solving this by writing 09:30, 09:31, 09:32, 09:33,...15:57, 15:58, 15:59, 16:00 and putting in numbers where fit (and blank cells for the rest), but Excel didn't seem to handle that when trying to create the chart.

    Uten navn.png

  3. #3
    Forum Contributor
    Join Date
    03-31-2010
    Location
    Norway
    MS-Off Ver
    Excel 365
    Posts
    632

    Re: Creating chart in VBA? Chart based on user selected date?

    Anyone?

    I see there's a possibillity to pay for services on this forum. I could pay for this project, but I'm not sure how much such a project will cost as I need to pre-pay, I think?

    Best regards.

  4. #4
    Forum Contributor
    Join Date
    03-31-2010
    Location
    Norway
    MS-Off Ver
    Excel 365
    Posts
    632

    Re: Creating chart in VBA? Chart based on user selected date?

    I hope it's okay with a final bump on this one. And if nobody can help me out (for free), maybe I could get some pointers on where to get it done paid for and how much. As mentioned, I know of the possibillity to pay for services here, but don't know what it would cost and if I'm guaranteed to have someone do this if I do buy points.

  5. #5
    Forum Contributor
    Join Date
    03-31-2010
    Location
    Norway
    MS-Off Ver
    Excel 365
    Posts
    632

    Re: Creating chart in VBA? Chart based on user selected date?

    Anyone?

    Maybe there's other ways to accomplish this?

    I'll gladly pay to get it done.

    Best regards.

    Elijah

  6. #6
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Creating chart in VBA? Chart based on user selected date?

    Maybe there is a smarter way to format/set up my data such that I can create charts directly from my tables?
    have you tried using a scatter chart instead of a line chart?

    i changed the second sheet to have scatter chart and added a DV to control the MIN/MAX of the axis

    you can incorporate this into your code of course ...i only set this out for demonstrative purposes
    Attached Files Attached Files
    Last edited by humdingaling; 04-22-2018 at 09:07 PM.
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  7. #7
    Forum Contributor
    Join Date
    03-31-2010
    Location
    Norway
    MS-Off Ver
    Excel 365
    Posts
    632

    Re: Creating chart in VBA? Chart based on user selected date?

    Hi, humdingaling,

    Thank you for your chart suggestion!

    It does look like an improvement for sure. I hadn't tried the scatter plot.

    I'm however a little embarrased to say that I don't quite understand how it works. What's DV?

    I see that the axis changes when I adjust the DV value, although I can't seem to see how (marking all the associated data and I only have cells C-F highlighted).

    Also, in case there was any confusion, for this data, I will always have the start value at 09:30 and the end time at 16:00.

    But the way my line charts end up, all points/swings will have similar length regardless of when they happen during the day and this is not quite correct...

    Thanks for any further advice on this matter.

    Best regards.

    Elijah

  8. #8
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Creating chart in VBA? Chart based on user selected date?

    don't quite understand how it works
    hmmm im not sure i can explain scatter/xy charts the best
    google is your friend in this case
    there is many videos out there if you find text dense sites a problem

    DV = Data validation....just to somehow control the outputs for the example...i'm not suggesting you use it in your final version

    although I can't seem to see how
    there is code in the background running that changes the MIN/MAX values of axis according to what value you choose from the data validation

    Also, in case there was any confusion, for this data, I will always have the start value at 09:30 and the end time at 16:00.
    again i put the min/max thru DV so you can see the effect it has on the what the chart looks like
    you can set it and forget it really


    i can see in by the coding you its rather "clean" so i had assumed you are adept at it already..unless of course someone else is coding for you
    the file i provided is more a demo file on min/max and scatter chart rather than solving your actual problem in this case

  9. #9
    Forum Contributor
    Join Date
    03-31-2010
    Location
    Norway
    MS-Off Ver
    Excel 365
    Posts
    632

    Re: Creating chart in VBA? Chart based on user selected date?

    Thanks a lot, humdingaling.

    I'll have to explore it further one day I get some better time.

    Not sure which coding you refer to? The formulas...?

    I still consider myself fairly basic with regards to Excel and have a LOT to learn.

  10. #10
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Creating chart in VBA? Chart based on user selected date?

    Not sure which coding you refer to? The formulas...?
    your VBA code

    personally, i actually tend to avoid using code like that
    its so truncated you actually have to look at it very carefully or my brain just isn't trained that way

+ 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. Replies: 1
    Last Post: 01-06-2018, 04:16 PM
  2. Creating chart based on user dropdown for x and y axis
    By matt3606 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 09-20-2017, 07:57 PM
  3. Creating a date based Gantt chart to track stock levels
    By freshchai in forum Excel General
    Replies: 1
    Last Post: 05-19-2017, 12:03 AM
  4. Creating a range for a chart based on cell date values
    By tinkerbelle in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-30-2015, 05:01 AM
  5. [SOLVED] Creating a chart that selects a range of data that is dependent on a value selected
    By FraserWM in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 01-28-2015, 11:58 AM
  6. [SOLVED] Creating a YTD total based on user selected value
    By curly45 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 07-21-2014, 06:46 AM
  7. Chart only user selected rows or columns with checkbox
    By tommypkoch in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 08-24-2013, 02:06 PM

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