+ Reply to Thread
Results 1 to 2 of 2

Copy chart from one worksheet to several

  1. #1
    Forum Contributor
    Join Date
    02-18-2013
    Location
    Berlin, Germany
    MS-Off Ver
    Excel 2016
    Posts
    221

    Copy chart from one worksheet to several

    Hello,

    I have a workbook with 12 sheets (named "january" to "december") which contain data blocks having the same structure. The first sheet ("january") has a chart with 4 lines referencing to data in the sheet. I want to copy this chart to the other 11 sheets and automatically adjust the data source for each sheet. How can this be done? I would appreciate a macro, because if I change the chart structure in the first sheet, then I could simply run the macro again.

    Thank you!

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Copy chart from one worksheet to several

    Hi excelactuary,

    Working with Excel Charts always seems more challenging than it should be, unless the 'Chart Wizard' does what you want.

    See the following code in Ordinary Code module ModChartCopy that is included in the attached sample file:
    Please Login or Register  to view this content.

    It is a best practice to declare all variables. If you misspell a variable in your code, VBA will silently assume it is a Variant variable and go on executing with no clue to you that you have a bug. Go to the VBA development window, click Tools, Options, and check "Require Variable Declaration." This will insert the following line at the top of all new modules:
    Please Login or Register  to view this content.
    This option requires all variables to be declared and will give a compiler error for undeclared variables.

    Notes:
    a. Charts for 'January' are created/deleted for Software Development purposes only.
    b. You can have any number of Charts of any type on Sheet 'January'.
    c. Two charts arbitrarily exist on Sheet 'January'.
    d. Data for both Charts is arbitrarily in 'A24:D26 (must preexist on each sheet in the same range)'.
    e. Each Sheet Name (formula) is arbitrarily stored in cell 'C20' (must preexist on each sheet in the same cell)'.
    f. Chart Title formulas are arbitrarily in cells 'A21' and 'A22' (must preexist on each sheet in the same range)'.
    g. Macro CopyAllChartsOnSheetJanuaryToSheetsFebruaryThruDecember() deletes existing Charts on Sheet 'February' thru 'December'
    and then copies all charts to Sheets 'February' thru 'December' .
    Formulas for the 'Title' and 'Data Series' are adjusted on Sheets 'February' thru 'December' .

    Months 'May' thru 'December' purposely do not exist in this workbook.

    Data for 'Harry' is different on all sheets to verify that reference changes work properly.


    Lewis
    Attached Files Attached Files

+ 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. copy a chart and table from a worksheet to slide no. 2
    By itsme2216 in forum Excel General
    Replies: 0
    Last Post: 02-13-2017, 10:38 AM
  2. copy a chart and table from a worksheet to slide no. 2
    By itsme2216 in forum Hello..Introduce yourself
    Replies: 2
    Last Post: 02-13-2017, 09:30 AM
  3. Replies: 11
    Last Post: 06-16-2015, 11:16 AM
  4. Replies: 4
    Last Post: 09-02-2014, 07:09 AM
  5. Replies: 0
    Last Post: 02-14-2011, 11:53 AM
  6. Replies: 1
    Last Post: 01-06-2011, 12:34 PM
  7. [SOLVED] How to copy Chart and its data to another excel worksheet
    By Margarita in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 04-19-2006, 09:10 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