jamescooper
Well-known Member
- Joined
- Sep 8, 2014
- Messages
- 834
Hello I insert the photo to appear in cell B8 at its original size.
How do I adapt the code below to make it perfectly fit over the range B8:F32?
Thanks.
How do I adapt the code below to make it perfectly fit over the range B8:F32?
Thanks.
VBA Code:
Sub Fit_to_Range()
Dim Pic_Location As String
Dim Pic_Name As String
'Set CellLoc as the cell that you want to fit the image into or any cell within the merged area you wish to place the image
Set CellLoc = Range("B8")
Pic_Name = "Front Page"
Pic_Location = "C:\Users\OneDrive - photos\22l\" & Pic_Name & ".jpg"
Set Pic = CellLoc.Parent.Pictures.Insert(Pic_Location)
With Pic
.Top = Range("B8").Top
.Left = Range("B8").Left
.Height = Range("B32").Top - Range("B8").Top
.Width = Range("F8").Left - Range("F8").Left
End With
End Sub