Remove the Calculate-event the try this one.
Private Sub Worksheet_Change(ByVal Target As Range)
Const numpix = 37.7952755905511 'pixels per cm
If Target.Address = "$P$3" Then
Dim mypic As Picture
Me.Pictures.Visible = False
With Range("e2")
For Each mypic In Me.Pictures
If mypic.Name = .Text Then
mypic.Visible = True
mypic.Top = .Top
mypic.Left = .Left
Exit For
End If
Next mypic
End With
Dim wpicture As String, s As Double, y As Double
With Sheet2
wpicture = .Cells(Application.Match(Target.Value, .Columns(1), 0), 2)
End With
With Sheet1
s = Round(.Shapes(wpicture).Height / numpix, 2)
y = Round(.Shapes(wpicture).Width / numpix, 2)
End With
MsgBox "Picture dimensions are " & vbLf & vbLf & _
"Height: " & s & " cm" & vbLf & vbLf & _
"Width: " & y & " cm"
End If
End Sub
Bookmarks