Insert Picture after deleting previous

mds33031

New Member
Joined
Jan 12, 2017
Messages
1
Hello,

I have a workbook that completes all forms needed for a client. The first sheet is where all my DATA is entered. On that first sheet, I paste a photo and it transfers it to multiple sheets. However When a new photo is added I need it to delete the previous photo. I am stuck and could use some help.

This is the VBA I am using to copy paste the picture to the other sheets.

Thanks in advance!

Sub CopyPic_FOW()
Dim pic As Shape, rng As Range, Lt As Double, Tp As Double
Application.ScreenUpdating = False
For Each pic In ActiveSheet.Shapes
If pic.Type = msoPicture Then
Lt = 460
Tp = 490
pic.Copy
With Sheets("FOW")
.Select
.Range(pic.TopLeftCell.Address).Select
.Paste
Selection.Top = Tp
Selection.Left = Lt
End With
Selection.Placement = xlMoveAndSize
End If
Next pic
Application.ScreenUpdating = True
Sheets("Data Entry").Select
Range("B2").Select
End Sub
 

Some videos you may like

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Perpa

Well-known Member
Joined
Dec 18, 2012
Messages
634
However When a new photo is added I need it to delete the previous photo. I am stuck and could use some help.

mds330131,
Welcome to the forum.
You didn't say how you paste the new photo to the 'first sheet', but before you paste the new photo to the active sheet, use this code to remove any existing photos on the active sheet:

Code:
Sub Remove_Shapes()
'>>The following will remove exisiting shapes on Sheet1
Dim sh As Shape
    For Each sh In Sheets("Sheet1").Shapes   'Change 'Sheet1' to your sheet name, or to  'ActiveSheet.Shapes'
       sh.Delete
    Next sh
 End Sub
Then you can add your new photo as before and continue with the rest of your code.
Perpa
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,122,469
Messages
5,596,328
Members
414,054
Latest member
Sameer50

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
Top