thank you for your prevoius codes
i wanted a vba code that picks a photo from folder basing on a drop down list at ref- U13 and display it at ref P2 and if the drop option has no image in the folder, a blank image be displayed for that option without returning any error message
the code i am having is
i wanted a vba code that picks a photo from folder basing on a drop down list at ref- U13 and display it at ref P2 and if the drop option has no image in the folder, a blank image be displayed for that option without returning any error message
the code i am having is
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
Dim myPict As Picture
Dim PictureLoc As String
If Target.Address = Range("U13").Address Then
ActiveSheet.Pictures.Delete
PictureLoc = "C:\PHOTO\" & Range("U13").Text & ".jpg"
With Range("P2")
On Error GoTo errormessage:
Set myPict = ActiveSheet.Pictures.Insert(PictureLoc)
myPict.Height = 300
myPict.Width = 200
myPict.Top = .Top
myPict.Left = .Left
myPict.Placement = xlMoveAndSize
myPict.ShapeRange.LockAspectRatio = msoTrue
errormessage:
If Err.Number = 1004 Then
MsgBox "File does not Exist, Please first update photo with .jpg File"
End If
End With
End If
Application.ScreenUpdating = True
End Sub
Last edited by a moderator: