Another handy place to use the UBound is with the ParamArray option of subs and fuctions
Private Sub Command1_Click()
MyCode "a", "b", 1
MyCode "Z", 1, "y", 4, "X"
End Sub
Sub MyCode(ParamArray Data() As Variant)
For x = 0 To UBound(Data)
Debug.Print Data(x)
Next
End Sub