Dear all, I am fairly new to get into VBA again after a couple of years abstinence. I have the following code that raises an error:
Public Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim ole As OLEObject
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 Me.OLEObjects
If Not (ActiveCell Is Nothing) Then
MsgBox (ole.Object.Value)
End If
ole.Delete
Next ole
CreateListBox (Target.Cells(1))
End If
End Sub
The Error is Object variable or With block variable not set. I am not sure why this is.
Thanks,
Hans
Bookmarks