+ Reply to Thread
Results 1 to 9 of 9

Repetitive charting on same graph

  1. #1
    Registered User
    Join Date
    07-11-2017
    Location
    Landau
    MS-Off Ver
    2010
    Posts
    47

    Repetitive charting on same graph

    This is what I am trying to do, tracing one single graph by picking out data from a repeated interval. I've attached an example file with the chart I want to generate.

    The logic is quite clean cut. But, I am not really sure how to translate it to VBA syntax.
    Basically, on the Active sheet, I want to perform the following operation.

    I have a repeating template of values.

    Floating cell= C4
    Floating range= FloatingCell to FloatingCell.offset(20,1)
    Chart the same with Q2 on x axis, Q 3 on Y axis.
    series name= D1

    Floating cell=C4+24
    Again, the corresponding range and chart it out on the same initial graph.
    Series name=D1 offset by 24 on the column.

    The charting should end when the floating cell basically find a value when it keeps going down. I have only 5 data sets in the example file here. But, the code is to enable me to deal with 500-600 such data sets.

    To add to the complication, I am developing a macros which will dynamically move the sheet down. i.e. when a new data set is taken, the latest one gets pasted on top and all the other values move down. I want the graphing to be able to accommodate and trace the latest values too. I am thinking clearing the graph and rerunning the loop is one way out. But, there might be something more efficient.
    Attached Files Attached Files
    Last edited by hegdep; 07-13-2017 at 05:03 AM.

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454

    Re: Repetitive charting on same graph

    Hi,

    The following code could be a place to start for you?

    Please Login or Register  to view this content.
    While it's not necessarily efficient, I would delete the whole chart and start again when new data is added. That can be achieved by adding this line to the start of the code

    Please Login or Register  to view this content.
    Last edited by sweep; 07-13-2017 at 05:17 AM. Reason: Spelling!
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Repetitive charting on same graph

    or a slight variation creating a new chart
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    07-11-2017
    Location
    Landau
    MS-Off Ver
    2010
    Posts
    47

    Re: Repetitive charting on same graph

    @Sweep

    This is a very good starting point. It could be bettered if I can loop it to many sheets.
    The only downside I see is that this needs a preset chart to work. If the naming of the chart could be set to the sheet name, it would make it a lot easier.
    I'll try to work with it.
    Thanks!

  5. #5
    Registered User
    Join Date
    07-11-2017
    Location
    Landau
    MS-Off Ver
    2010
    Posts
    47

    Re: Repetitive charting on same graph

    Quote Originally Posted by NickyC View Post
    or a slight variation creating a new chart
    Please Login or Register  to view this content.
    This seems to be a more well organized code, logically.
    However, when I try to run it, I get an error message saying "object doesn't support this property or method". I am presuming this has got to do with the type of graph selected.
    When I remove the AddChart2 and make it plainly AddChart, it traces up a histogram. Is there any reference about the codes for the types of graphs? If yes, it would be helpful to have one.

  6. #6
    Registered User
    Join Date
    07-11-2017
    Location
    Landau
    MS-Off Ver
    2010
    Posts
    47

    Re: Repetitive charting on same graph

    Quote Originally Posted by sweep View Post
    Hi,

    The following code could be a place to start for you?

    Please Login or Register  to view this content.
    While it's not necessarily efficient, I would delete the whole chart and start again when new data is added. That can be achieved by adding this line to the start of the code

    Please Login or Register  to view this content.
    What is the syntax I must use to run this code with ActiveSheet instead of using Sheet 1? Especially to replace "=Sheet1!$D$"
    Thanks for your help?

  7. #7
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Repetitive charting on same graph

    Hi
    your problem with my code could be a version issue. Try this variation:
    Please Login or Register  to view this content.

  8. #8
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454

    Re: Repetitive charting on same graph

    Quote Originally Posted by hegdep View Post
    What is the syntax I must use to run this code with ActiveSheet instead of using Sheet 1? Especially to replace "=Sheet1!$D$"
    Thanks for your help?
    I guess this will do what you need.

    Please Login or Register  to view this content.
    If you wanted to create a new chart, and name it relative to the sheet name, you'd need somecode like this at the start of the routine...

    Please Login or Register  to view this content.
    To loop through all worksheets, wrap a for....each....in.....next loop around the code

    and refer to the sheet ws in the code

    Please Login or Register  to view this content.
    Altogether, this might be work for you.

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    07-11-2017
    Location
    Landau
    MS-Off Ver
    2010
    Posts
    47

    Re: Repetitive charting on same graph

    Thanks a ton! I figured it out earlier today, it was a little more complicated than that, because I had to play between sheets. I really appreciate you breaking this down for me.
    Last edited by AliGW; 07-14-2017 at 09:08 AM. Reason: Unnecessary quotation deleted.

+ 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. Creating Repetitive Dynamic Graph in multiple worksheet using VBA
    By geniuskhan in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 07-04-2017, 10:39 AM
  2. complex charting/graph
    By tlbw73 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 02-25-2015, 03:44 PM
  3. Charting Help- Stacked Bar Graph
    By NicoSauve in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 08-13-2013, 09:58 PM
  4. Charting a column graph from a worksheet with grouping option
    By Marian_N in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 06-06-2013, 07:55 AM
  5. Markers of graph (conditional charting)
    By Beginner Level in forum Excel General
    Replies: 1
    Last Post: 03-03-2012, 06:01 PM
  6. Charting a 3D graph?
    By mjgallacher in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 11-30-2007, 12:12 PM
  7. Help with charting my own y values on a graph
    By frogger in forum Excel General
    Replies: 0
    Last Post: 02-23-2006, 10:48 AM

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