+ Reply to Thread
Results 1 to 11 of 11

multiple chart loop

  1. #1
    Forum Contributor
    Join Date
    10-22-2014
    Location
    Indonesia
    MS-Off Ver
    2010
    Posts
    177

    multiple chart loop

    Hi,

    I am learning how to create chart using vba.

    this one is using recorder to create first chart.

    Please Login or Register  to view this content.
    attached is example file ( with manual result ).

    I wonder how to repeat the process to create another chart for every four data ( start from 1 and end with 4) until last cell.
    with the chart title: date of first cell of every batch.

    Appreciate for any help.

    Thank you.
    Attached Files Attached Files

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: multiple chart loop

    Hi,

    Perhaps this
    Please Login or Register  to view this content.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Forum Contributor
    Join Date
    10-22-2014
    Location
    Indonesia
    MS-Off Ver
    2010
    Posts
    177

    Re: multiple chart loop

    Hi,

    That's great! work as i expected.

    I have few questions,

    If ((n - 2) \ 4) Mod 2 = 0 Then
    chartLeft = Range("E1").Left
    chartTop = ((n - 2) \ 8) * chartHeight + Cells(2, "E").Top

    1. what is the meaning of those number?
    (n-2)\4 Mod 2 = 0
    ((n-2)\8)

    2. which part should i modified, if i want the chart from 2 ( col E and K) to 4 ( E, J , O, T) per row.

    3. how to modify the seriescollection X axis . Current result for x axis is 1,2,3,4 , when i change 1,2,3,4 to 2,4,6,8, the x axis resulted using vba is still 1,2,3,4


    Thank you for your time.

  4. #4
    Forum Contributor
    Join Date
    10-22-2014
    Location
    Indonesia
    MS-Off Ver
    2010
    Posts
    177

    Re: multiple chart loop

    any help from other?

    still struggling to modify the code.

  5. #5
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: multiple chart loop

    For the positions you could replace this part
    Please Login or Register  to view this content.
    with this (untested)
    Please Login or Register  to view this content.
    Should the code be using a range for the X axis labels?

  6. #6
    Forum Contributor
    Join Date
    10-22-2014
    Location
    Indonesia
    MS-Off Ver
    2010
    Posts
    177

    Re: multiple chart loop

    Thank you for reviewing back my code.

    Got compile error: next without for

    current result for X, is sequence number 1,2,3,4. the actual will not always 1,2,3,4.

  7. #7
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: multiple chart loop

    I think you replaced too many lines. What code do you have at the moment?

    How should the code determine the correct X axis labels?

  8. #8
    Forum Contributor
    Join Date
    10-22-2014
    Location
    Indonesia
    MS-Off Ver
    2010
    Posts
    177

    Re: multiple chart loop

    Hi,

    Thank you. its work now.
    i accidentally delete For n = 2 To lastRow Step 4 causing error : Next without for

    nevermind about the x axis, i don't need it.

    anyway, how to give space/gap with chart below? current result is first row chart is stick to second row chart.

    Thank you so much, you help me learn about chart vba .

  9. #9
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: multiple chart loop

    You can add a gap like this
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    10-22-2014
    Location
    Indonesia
    MS-Off Ver
    2010
    Posts
    177

    Re: multiple chart loop

    Hi,

    actually i practice with different set ( 13 data per chart) previously 4 data per chart.

    but can't get it right, the charts is overlapping another chart.

    attach is the update file contain macro.
    Attached Files Attached Files

  11. #11
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: multiple chart loop

    I've added two new constants for the number of rows to use per chart and the gap between chart rows
    Please Login or Register  to view this content.

+ 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. [SOLVED] Possible Do UNTIL Loop in Chart
    By electric17 in forum Excel General
    Replies: 2
    Last Post: 05-25-2017, 08:03 AM
  2. [SOLVED] VBA to loop within a loop of multiple blocks of data (currentregion) ... Expert needed
    By Jim885 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-20-2016, 08:28 PM
  3. Loop through multiple files and call macros (but unable to loop)
    By ryanpetersen in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-23-2014, 12:04 PM
  4. [SOLVED] Loop & Create Chart
    By FixandFoxi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-27-2014, 11:49 AM
  5. Defining multiple chart ranges via a conditioned loop
    By seanpears99 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-26-2012, 10:34 PM
  6. chart loop with 12 series
    By sport_logo in forum Excel Charting & Pivots
    Replies: 6
    Last Post: 05-29-2010, 09:30 AM
  7. Chart and Loop
    By mister tom in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-16-2010, 09:53 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