Add copy charts and shapes with the present script for copy tabs of workbook to new workbook

Malhotra Rahul

Board Regular
Joined
Nov 10, 2017
Messages
92
Hi I am using the below script for copying specific worksheets from a workbook. I want to add for copy multiple Charts and Shapes as picture. Charts as Chart No. 71, 24 & 35 and Shape as Rectangle 53, 54 & 54.

Code:
Option ExplicitSub RunMacro1_Click()
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Application.EnableEvents = False
Dim NewName As String, s As String, wb As Workbook, ws As Worksheet, i As Integer, X
    
    s = "Report & Product Analysis & Customer Analysis"  '//EDIT OR ADD SHEETS TO BE COPIED HERE (INCLUDE '<space>&<space>' BETWEEN NAMES)
    X = Split(s, " & ")
    
    If MsgBox("Sheets:" & vbCr & vbCr & s & vbCr & vbCr & "will be copied to a new workbook" & vbCr & vbCr & _
    "The sheets will be values only (named ranges, formulas and links removed)" & vbCr & vbCr & _
    "Do you want to continue?", vbYesNo, "Create New Workbook") = vbNo Then Exit Sub
    
    NewName = InputBox("Please Enter the name for the new workbook", "New Workbook Name")


    Application.ScreenUpdating = False
    Workbooks.Add
    Set wb = ActiveWorkbook
    With wb
        For i = 0 To UBound(X)
            Set ws = ThisWorkbook.Sheets(X(i))
            ws.Cells.Copy
            .Sheets.Add after:=Sheets(Sheets.Count): .ActiveSheet.Name = X(i)
            With .Sheets(X(i))
                .Cells.SpecialCells (xlCellTypeVisible)
                .[A1].PasteSpecial Paste:=xlValues
                .Cells.PasteSpecial Paste:=xlFormats
                .Cells.Hyperlinks.Delete
                
                Application.Goto .[A1]
            End With
        Next
        Worksheets("Variance").Visible = True
        Worksheets("Variance").Activate
        ActiveWindow.DisplayGridlines = False
        ActiveWindow.DisplayHeadings = False
        Application.DisplayFullScreen = True
        Application.DisplayAlerts = False
        For i = 1 To 1
            .Sheets("Sheet" & i).Delete
                
        .Colors = ThisWorkbook.Colors
                
        .SaveAs (NewName & ".xls")
       Next i
       End With
      
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub

Any help would be highly appreciated. Thank you in advance.</space></space>
 
Last edited:

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hi, May i expect the upgraded script. Charts as Chart No. 71 & Shape 53 is located in worksheet "Report" , Chart 24 and Shape 54 is located in worksheet Product Analysis, & Chart 35 and Shape 54 is located in worksheet Customer Analysis.

Please help me
 
Upvote 0
May i expect to look into my thread and help me. Thank you in advance for your support. Any help would be highly appreciated.
 
Upvote 0

Forum statistics

Threads
1,214,839
Messages
6,121,891
Members
449,058
Latest member
Guy Boot

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top