Copy Multiple Pictures from 1 Sheet and Paste to Multiple Others In Same Location

Pepperdine21

New Member
Joined
Jul 9, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I am trying to copy 3 pictures from a sheet titled "Hidden" and paste them in cell B2 of each sheet using a for loop.

Here is my current code. I get no error messages but nothing pastes in any of the desired sheets.

dim Sht as Worksheet

For Each Sht In Worksheets
If Not Sht.Name = "Intro" Then
Worksheets("Hidden").Select
ActiveSheet.Shapes.Range(Array("Picture 8", "Picture 7", "Picture 9")).Select
Selection.Copy

Sht.Activate
Sht.Select
Sht.Range("B1").PasteSpecial

End If
Next


-TIA
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
You can first group those shapes, then copy them to each of the target worksheets, and then ungroup them. The following macro assumes that the workbook containing the relevant worksheets is the active workbook. If, however, the workbook containing the relevant worksheets is the workbook running the code, you should qualify your worksheet references . . .

VBA Code:
Set GrpShp = ThisWorkbook.Worksheets("Hidden").Shapes.Range(Array("Picture 8", "Picture 7", "Picture 9")).Group

Here's the code . . .

VBA Code:
Option Explicit

Sub test()

    Dim Sht As Worksheet
    Dim GrpShp As Shape
 
    Set GrpShp = Worksheets("Hidden").Shapes.Range(Array("Picture 8", "Picture 7", "Picture 9")).Group
 
    GrpShp.Copy
 
    For Each Sht In Worksheets
        If Sht.Name <> "Intro" And Sht.Name <> "Hidden" Then
            Sht.Paste Sht.Range("B1")
            With Sht
                .Shapes(.Shapes.Count).Ungroup
            End With
        End If
    Next
 
    GrpShp.Ungroup

End Sub

By the way, for efficiency, you should set ScreenUpdating to False at the beginning of the code, and then back to True and the end of it...

VBA Code:
Option Explicit

Sub test()

    Dim Sht As Worksheet
    Dim GrpShp As Shape
 
    Application.ScreenUpdating = False
 
    Set GrpShp = Worksheets("Hidden").Shapes.Range(Array("Picture 8", "Picture 7", "Picture 9")).Group
 
    GrpShp.Copy
 
    For Each Sht In Worksheets
        If Sht.Name <> "Intro" And Sht.Name <> "Hidden" Then
            Sht.Paste Sht.Range("B1")
            With Sht
                .Shapes(.Shapes.Count).Ungroup
            End With
        End If
    Next
 
    GrpShp.Ungroup
 
    Application.ScreenUpdating = True

End Sub

Hope this helps!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,045
Messages
6,122,836
Members
449,096
Latest member
Erald

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