In userform1, I have the following code
Private Sub cmdOK_Click()
Dim i As Long
With Me.ListBox2
If .ListCount = 0 Then MsgBox "You Have To Select At Least One Column", vbExclamation: GoTo Skipper
ReDim aCols(0 To .ListCount - 1)
For i = 0 To .ListCount - 1
aCols(i) = "[" & ListBox2.List(i, 0) & "]"
Next i
End With
Skipper:
Unload Me
End Sub
and in standard module I declared aCols as public
Public aCols
if listbox2 has no items then aCols became Empty while if there are items the aCols became an array .. Then in another code I am confused of how to avoid errors
If UBound(aCols) > -1 Then
This works fine if aCols is not empty but I encountered errors if aCols is Empty .. How to deal with both cases Simply I need to avoid the errors and deal with aCols either it is empty or either it is an array.