Macro to Copy/Paste Multiple images

L

lfullam1

Hello All,

I have 7 pictures on one worksheet that I want to copy and paste on t
another worksheet, into various cells. Each image will go into only on
cell. The code I have is as follows:

Sub Picture()
'
' Picture Macro
'

'
Sheets("info").Shapes("Picture 5").Select
Selection.Copy
Sheets("bat").Select
With Worksheets("bat")
.Paste Destination:=.Range("B131")
End With

Sheets("info").Shapes("Picture 2").Select
Selection.Copy
Sheets("bat").Select
With Worksheets("bat")
.Paste Destination:=.Range("A202")
End With

Sheets("info").Shapes("Picture 3").Select
Selection.Copy
Sheets("bat").Select
With Worksheets("bat")
.Paste Destination:=.Range("d202")
End With

Sheets("info").Shapes("Picture 4").Select
Selection.Copy
Sheets("bat").Select
With Worksheets("bat")
.Paste Destination:=.Range("A209")
End With

Sheets("info").Shapes("Picture 5").Select
Selection.Copy
Sheets("bat").Select
With Worksheets("bat")
.Paste Destination:=.Range("D209")
End With

Sheets("info").Shapes("Picture 6").Select
Selection.Copy
Sheets("bat").Select
With Worksheets("bat")
.Paste Destination:=.Range("A216")
End With

Sheets("info").Shapes("Picture 7").Select
Selection.Copy
Sheets("bat").Select
With Worksheets("bat")
.Paste Destination:=.Range("D216")

End With

End Sub

The issue I am running into is that it is pasting Picture 1 into all
destinations, instead of the specified picture it should b
selecting...I could be overlooking something here completely, but
can't seem to figure this out

Thoughts/Help?

Thank
 
C

Claus Busch

Hi,

Am Thu, 9 May 2013 18:12:49 +0100 schrieb lfullam1:
I have 7 pictures on one worksheet that I want to copy and paste on to
another worksheet, into various cells. Each image will go into only one
cell. The code I have is as follows:

try:
Sub myCopy()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim shp As Shape

j = 1
k = 202
Application.ScreenUpdating = False
With Sheets("info")
For i = 2 To 7
.Shapes("Picture " & i).Copy
Sheets("bat").Paste
Next
End With
With Sheets("bat")
For i = 2 To 7
.Shapes("Picture " & i).Top = .Cells(k, j).Top
.Shapes("Picture " & i).Left = .Cells(k, j).Left
If i Mod 2 = 0 Then
j = j + 3
Else
j = 1
k = k + 7
End If
Next
End With
Application.ScreenUpdating = True
End Sub


Regards
Claus Busch
 
L

lfullam1

Claus said:
Hi,

Am Thu, 9 May 2013 18:12:49 +0100 schrieb lfullam1:
-

try:
Sub myCopy()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim shp As Shape

j = 1
k = 202
Application.ScreenUpdating = False
With Sheets("info")
For i = 2 To 7
.Shapes("Picture " & i).Copy
Sheets("bat").Paste
Next
End With
With Sheets("bat")
For i = 2 To 7
.Shapes("Picture " & i).Top = .Cells(k, j).Top
.Shapes("Picture " & i).Left = .Cells(k, j).Left
If i Mod 2 = 0 Then
j = j + 3
Else
j = 1
k = k + 7
End If
Next
End With
Application.ScreenUpdating = True
End Sub


Regards
Claus Busch

Thanks for the help. This was only partially successful though. I nee
to be able to have each image go to a specific place. Also, there ar
other images in the two worksheets that shouldn't be moved, only th
seven in question, named Picture 1...Picture7.

Any other thoughts or tweeks
 
C

Claus Busch

Hi,

Am Thu, 9 May 2013 20:23:32 +0100 schrieb lfullam1:
I need
to be able to have each image go to a specific place. Also, there are
other images in the two worksheets that shouldn't be moved, only the
seven in question, named Picture 1...Picture7.

but that is exactly what the code does. You only get problems, if on
sheet "bat" already are pictures with name 1 to 7. Then you have to
change the name of the copied pictures.


Regards
Claus Busch
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top