Const ImageCellRef = "AD25"
Const CurrentImage = "MyPic"
Const ImageSheet = "YTShow"
Const ListSheet = "YTShow"
Sub show_Button11_Click()
Dim ImageName As String, ImagePath As String
Dim sh As Worksheet: Set sh = Sheets(ImageSheet)
Dim ws As Worksheet: Set ws = Sheets(ListSheet)
'delete current image
sh.Activate
On Error Resume Next
sh.Shapes(CurrentImage).Delete
On Error GoTo 0
sh.Range(ImageCellRef).Select
'next image (insert my image cycling code here)
ImagePath = Range("AF66")
'insert image
On Error Resume Next
sh.Pictures.Insert(ImagePath).Select
With Selection
.Name = "MyPic"
.ShapeRange.LockAspectRatio = msoTrue
.ShapeRange.Height = ActiveCell.Height
End With
'Rng.Value = "used"
sh.Range("AD25").Select
'============================================
With Range("AD25")
MyPic.Left = .Left + ((.Width - MyPic.Width) / 2)
MyPic.Top = .Top + ((.Height - MyPic.Height) / 2)
End With
End Sub
Bookmarks