(Solved) – vba macro copies all charts twice instead of once

(solved)-–-vba-macro-copies-all-charts-twice-instead-of-once

This vba macro copies all charts to a temp sheet, it is working well however it seems to copy every chart twice instead of once. How can I modify the code so that it doesn’t duplicate each chart?

Sub macro1()

Dim i As Long, j As Long, k As Long
Dim adH As Long
Dim Rng As Range
Dim FilePath As String: FilePath = ThisWorkbook.Path & ""
Dim sht As Worksheet, shtSource As Worksheet, wk As Worksheet
'===================================================================
'===================================================================
Sheets.Add After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
ActiveSheet.Name = "ALL"
Set sht = ActiveSheet
'===================================================================
Application.ScreenUpdating = False
'===================================================================
'Excluding fixed tab, copying all charts from all tabs to ALL
For Each wk In Worksheets
    If wk.Name <> "fixed" Then
        Application.DisplayAlerts = False
            j = wk.ChartObjects.Count
                For i = 1 To j
                    wk.ChartObjects(i).Activate
                    ActiveChart.ChartArea.Copy
                    sht.Select
                    ActiveSheet.Paste
                    sht.Range("A" & 1   i & "").Select
                 Next i
        Application.DisplayAlerts = True
    End If
Next

Leave a Reply

Your email address will not be published. Required fields are marked *