Moonbeam111
Board Regular
- Joined
- Sep 24, 2018
- Messages
- 56
- Office Version
- 365
- 2010
Hey everyone. I have a picture code and what I want it to do is replace the picture instead of put it on top of it. Here is the code
The picture I need is currently taken from one of the folders in my hard drive and automatically put in excel via a worksheet change event by matching the name of the file to the name of the excel cell. However, as mentioned it doesn't replace the picture it just puts it on top and I don't like to have to delete the picture every time before i put in a new one in its spot.
VBA Code:
Sub Button396_Click()
Dim myR As Range
Set myR = Range("C11:J20")
myR.Select
Dim picname As String
picname = "" & Range("F7") & ".png" 'Link to the picture
With ActiveSheet
Set Picture = .Pictures.Insert(picname)
With Picture
With .ShapeRange
.LockAspectRatio = msoFalse
.Width = 700
.Height = 150
.ZOrder msoSendToBack
End With
End With
End With
Exit Sub
End Sub
The picture I need is currently taken from one of the folders in my hard drive and automatically put in excel via a worksheet change event by matching the name of the file to the name of the excel cell. However, as mentioned it doesn't replace the picture it just puts it on top and I don't like to have to delete the picture every time before i put in a new one in its spot.