Sub LoopComboBoxes()
Dim OleObj As OLEObject, cel As Range
For Each OleObj In ActiveSheet.OLEObjects
If OleObj.progID = "Forms.ComboBox.1" Then
On Error Resume Next
Set cel = Range(OleObj.LinkedCell)
If IsError(cel) Then
If cel.Value = CVErr(xlErrRef) Then OleObj.Delete
End If
Set cel = Nothing
End If
Next OleObj
End Sub
Sub LoopShapes()
Dim shp As Shape, cel As Range
For Each shp In ActiveSheet.Shapes
On Error Resume Next
If Left(shp.Name, 9) = "[COLOR=#000080]Drop Down[/COLOR]" Then
Set cel = Range(shp.ControlFormat.LinkedCell)
If IsError(cel) Then
If cel.Value = CVErr(xlErrRef) Then shp.Delete
End If
Set cel = Nothing
End If
Next
End Sub
correction to above post - it is the ComboBox Edit button that is greyed out
NON active-x comboboxes
This may work for Form Control combo boxes
- I never use these but they appear to be named "Drop Down 1" etc by default
- check to see how they are named (by right-clicking on them) and amend the condition if necessary
Code:Sub LoopShapes() Dim shp As Shape, cel As Range For Each shp In ActiveSheet.Shapes On Error Resume Next If Left(shp.Name, 9) = "[COLOR=#000080]Drop Down[/COLOR]" Then Set cel = Range(shp.ControlFormat.LinkedCell) If IsError(cel) Then If cel.Value = CVErr(xlErrRef) Then shp.Delete End If Set cel = Nothing End If Next End Sub
Code in post#3 works for active-x comboboxes
(correction was only on note re Form Control Comboboxes )
Sub LoopComboBoxes()
Dim OleObj As OLEObject
For Each OleObj In ActiveSheet.OLEObjects
With OleObj
If .progID = "Forms.ComboBox.1" And .LinkedCell = "#REF!" Then OleObj.Delete
End With
Next OleObj
End Sub