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
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
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:
Upvote 0

Forum statistics

Threads
1,214,858
Messages
6,121,960
Members
449,057
Latest member
FreeCricketId

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