Const strPicturePath As String = "D:Employee PicturePic"
Const strPictureExtension As String = ".bmp"
Const strPictureColumn As String = "E"
Private Sub Worksheet_Change(ByVal Target As Range)
Dim strFileName As String
If Target.Column = 1 Then
If Not IsNull(Target(1, 1)) Then
strFileName = strPicturePath & Target(1, 1) & strPictureExtension
If Not IsNull(Dir(strFileName)) Then
InsertPicture strFileName, Range(strPictureColumn & Target(1, 1).Row)
End If
End If
End If
End Sub
Sub InsertPicture(PictureFileName As String, TargetCell As Range)
On Error GoTo ErrorHandle
Dim objPicture As Object
Dim dblTop As Double
Dim dblLeft As Double
Dim dblWidth As Double
Dim dblHeight As Double
Set objPicture = ActiveSheet.Pictures.Insert(PictureFileName)
With TargetCell
dblTop = .Top
dblLeft = .Left
End With
With objPicture
.Top = dblTop
.Left = dblLeft
End With
Set objPicture = Nothing
Exit Sub
ErrorHandle:
'Do nothing
End Sub