Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8566931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:46:08+00:00 2026-06-11T17:46:08+00:00

I have several worksheets which have different data but organized in the same way

  • 0

I have several worksheets which have different data but organized in the same way (same number of col and rows). I created several charts in sheet1 which I would like to copy to sheet2. while the normal copy/paste copies the charts to sheet2, the charts is still referring to data in sheet1, not in sheet2. How can I automatically make them use sheet2 data rather than sheet after copying?

As a work around, I tried copying sheet1 and called it sheet2 (which copies all data and charts), then copy and pasted the real sheet2 data in this new sheet. This works, but I was hoping there is a faster way and perhaps a macro that copies all charts from sheet1 to sheet2 and automatically updates the references.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:46:09+00:00Added an answer on June 11, 2026 at 5:46 pm

    So something like this worked for me. CopyCharts copies all charts from a source sheet to a target sheet. Then SetChartRef sets the reference of the charts in the target to what I want them to be. In this example I know which chart number is what. I guess it can be improved so that it uses the chart names instead.

    Also, for some reason I get run time errors if I don’t have delays between copying and pasting, hence the wait functions.

        Sub DeleteEmbeddedCharts(target As String)
    
        Dim wsItem As Worksheet
        Dim chtObj As ChartObject
            For Each chtObj In ThisWorkbook.Worksheets(target).ChartObjects
                chtObj.Delete
            Next
    End Sub
    
    Sub SetChartRef(target As String)
    
        Dim cht As ChartObject
        Dim i As Integer
    
        'i specifies which chart to set its data references
        i = 0
        For Each cht In ThisWorkbook.Worksheets(target).ChartObjects
            If i = 0 Then
                cht.Chart.SeriesCollection(1).Values = "=" & target & "!$I$2:$I$12"
                cht.Chart.SeriesCollection(2).Values = "=" & target & "!$J$2:$J$12"
            ElseIf i = 1 Then
                 cht.Chart.SeriesCollection(1).Values = "=" & target & "!$I$14:$I$25"
                 cht.Chart.SeriesCollection(2).Values = "=" & target & "!$J$14:$J$25"
            ElseIf i = 2 Then
                cht.Chart.SeriesCollection(1).Values = "=" & target & "!$I$26:$I$37"
                cht.Chart.SeriesCollection(2).Values = "=" & target & "!$J$26:$J$37"
            ElseIf i = 3 Then
                cht.Chart.SeriesCollection(1).Values = "=(" & target & "!$H$2," & target & "!$H$14," & target & "!$H$26," & target & "!$H$38)"
                cht.Chart.SeriesCollection(1).XValues = "=(" & target & "!$E$2," & target & "!$E$14," & target & "!$E$26," & target & "!$E$38)"
             ElseIf i = 4 Then
                cht.Chart.SeriesCollection(1).Values = "=(" & target & "!$H$2," & target & "!$H$14," & target & "!$H$26," & target & "!$H$38)"
                cht.Chart.SeriesCollection(1).XValues = "=(" & target & "!$E$2," & target & "!$E$14," & target & "!$E$26," & target & "!$E$38)"
            ElseIf i = 5 Then
                cht.Chart.SeriesCollection(1).Values = "=" & target & "!$I$38:$I$49"
                cht.Chart.SeriesCollection(2).Values = "=" & target & "!$J$38:$J$49"
            End If
            i = i + 1
        Next
    
    
    End Sub
    
    Sub CopyCharts(source As String, target As String)
    
        Dim chtObj As ChartObject
        'First delete all charts from target sheet
        DeleteEmbeddedCharts (target)
    
        'Some delay
        Application.Wait Now + TimeSerial(0, 0, 1)
    
        For Each chtObj In ThisWorkbook.Worksheets(source).ChartObjects
            With ThisWorkbook.Worksheets(target)
                .Activate
                chtObj.Copy
                'Paste in row T1+i
                Range("T1").Offset(i).Select
                .Activate
                Application.Wait Now + TimeSerial(0, 0, 1)
                .Paste
                Application.Wait Now + TimeSerial(0, 0, 1)
                i = i + 10
                .Activate
            End With
        Next chtObj
    
        'Set the data references to target sheet
        SetChartRef (target)
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a several columns in my excel worksheets which are all named as
I have several excel sheets which I'd like to work with different Excel versions
Need some help with the following: I have several worksheets with the same structure
I have several C files. and I created a function which is named X_STRING(arg1,arg2,arg3,arg4);
I have several different sites in different hosts and I use the same JS
I have an Excel Workbook that has several worksheets in it. The tables in
I have several xml files with different node structure. I want to extract xml
I have several HTML elements (buttons) that fire the same JQuery AJAX request. When
I have several different numbers in a group that range in sizes and would
I have several xml files that are formated this way: <ROOT> <OBJECT> <identity> <id>123</id>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.