OzGrid

How to create a macro that copies all of the tables and charts on a sheet and pastes them as an image onto another sheet

< Back to Search results

 Category: [Excel]  Demo Available 

How to create a macro that copies all of the tables and charts on a sheet and pastes them as an image onto another sheet

 

Requirement:

 

The user has added a macro that copies all of the tables and charts on a sheet and pastes them as an image onto another sheet.

This works fine for the first go, but if the user runs it subsequent times the user get sa Debug error to do with a named Picture (ActiveSheet.Shapes.Range(Array("Picture 16")).Select) . The user guesses that each time the macro is run the image name is automatically changed?

The user wants to know there a way round this at all?

Code:
Sub PPack()
'
' Test Macro
'
'
    Sheets("Sheet_Name_1").Select
    Range("B3:AG317").Select
    Selection.Copy
    Sheets("Sheet_Name_2").Select
    Range("B2").Select
    ActiveSheet.Pictures.Paste.Select
    ActiveSheet.Shapes.Range(Array("Picture 16")).Select
End Sub

 

https://www.ozgrid.com/forum/forum/help-forums/excel-vba-macros/149549-paste-as-image-no-links-only-works-once

 

Solution:

 

Code:
ActiveSheet.Shapes(1).Select

 

Obtained from the OzGrid Help Forum.

Solution provided by sktneer.

 

See also: Index to Excel VBA Code and Index to Excel Freebies and Lesson 1 - Excel Fundamentals and Index to how to… providing a range of solutions and Index to new resources and reference sheets

 

See also:

How to generate multiple line charts VBA
How to resize word charts/pictures in excel
How to automate charts with 1 x - axis and multiple y - axis in VBA
How to generate multiple line charts VBA

 

Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.


Gallery



stars (0 Reviews)