Hello Hans,
OLEObjects have an Object property. Setting an object variable equal to this property allows you to acces the methods, events, and properties of the object it represents. Here are the corrections to your code.
Public Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim ole As Object
Dim obj As Object
If Target.Column > 1 And Target.Column < 9 _
And Target.Row > 1 And _
Range("A" & (Target.Row)).Value <> ""
Then
'Remove all OLEObjects from sheet
For Each ole In ActiveSheet.OLEObjects
Set obj = ole.Object
If Not (ActiveCell Is Nothing) Then
MsgBox (obj.Value)
End If
obj.Delete
Next ole
CreateListBox (Target.Cells(1))
End Sub
Sincerely,
Leith Ross
Bookmarks