I have realized I need to trap for an error when a Shape on the Structures sheet does not exist. So when
.Column(1, .ListCount - 1) = Worksheets("Structures").Shapes(Struct.Text).Name
errors because that Shape does not exist I want to referance
.Column(1, .ListCount - 1) = Worksheets("Structures").Shapes("Blank").Name
I have tried
But then the user gets an error when they select an item that does not have an associated Shape. So I wanted to bring up a shape named Blank instead.
Here is the code. Currently I am getting a Compile Error, Invalid, Unqualified referance in the last line before the End.
Dim LastRow As Long
Dim StartRow As Long
Dim Wks As Worksheet
Set Wks = Worksheets("TOC")
StartRow = 3
LastRow = Wks.Cells(Rows.Count, "A").End(xlUp).Row
n = 0
With ComboBox1
For Each Struct In Wks.Range(Cells(StartRow, "A"), Cells(LastRow, "A"))
.AddItem
.Column(0, .ListCount - 1) = Struct.Text
Select Case Struct
Case Is = "#6", "#7", "#8"
.Column(1, .ListCount - 1) = Worksheets("Structures").Shapes("#6").Name
Case Else
.Column(1, .ListCount - 1) = Worksheets("Structures").Shapes(Struct.Text).Name
End Select
On Error GoTo NoStruct
Next Struct
End With
ComboBox1.ListIndex = 0
NoStruct:
.Column(1, .ListCount - 1) = Worksheets("Structures").Shapes("Blank").Name
End Sub
Bookmarks