Welcome to the forum! Please paste code between code tags. Click the # icon to insert the tags.
This does not do what you want but it might help. This keeps the picture's ratio the same. By making both the height and width the same as the cell, you could distort the image.
In this macro, the base file name like "ken" would be in the cell to the left of the activecell. The activecell is where the picture is imported and resized.
Sub ken()
Dim fn As String, pic As Object, r As Range
Set r = ActiveCell
fn = "c:\myfiles\excel\pics\" & r.Offset(, -1).Value2 & ".jpg"
If Len(Dir(fn)) = 0 Then
MsgBox "File: & fn & vblf & does not exist. Macro is ending", vbCritical, "Error"
Exit Sub
End If
Set pic = ActiveSheet.Pictures.Insert(fn)
FitPic r, pic
End Sub
'http://www.extendoffice.com/documents/excel/1060-excel-resize-picture-to-fit-cell.html
'Revised by Kenneth Hobson
Sub FitPic(aCell As Range, pic As Object)
Dim CellWtoHRatio As Single, PicWtoHRatio As Single
On Error GoTo NOT_SHAPE
With pic
PicWtoHRatio = .Width / .Height
End With
With aCell
CellWtoHRatio = .Width / .RowHeight
End With
Select Case PicWtoHRatio / CellWtoHRatio
Case Is > 1
With pic
.Width = aCell.Width
.Height = .Width / PicWtoHRatio
End With
Case Else
With pic
.Height = aCell.RowHeight
.Width = .Height * PicWtoHRatio
End With
End Select
With pic