Is there a mistake/typo in the help file here:
Split function (Visual Basic for Applications) | Microsoft Docs
Should "arrSplitStrings1()" and "arrSplitStrings2()" not be declared as Strings rather than Variants?
Code:
Sub Demo2()
Dim strFull As String
Dim arrSplitStrings1() As Variant
Dim arrSplitStrings2() As Variant
Dim str1 As String, str2 As String, str3 As String
Dim i As Long
' String that will be used:
strFull = "Some - Old - Hags - Can - Always - Hide - Their - Old - Age"
arrSplitStrings1 = Split(strFull, "-")
arrSplitStrings2 = Split(strFull, " - ")
str1 = arrSplitStrings2(3) ' str1 = "Can".
str2 = Split(strFull, " - ")(3) ' str2 = "Can".
For i = LBound(arrSplitStrings2, 1) To UBound(arrSplitStrings2, 1)
If InStr(1, arrSplitStrings2(i), "Can", vbTextCompare) > 0 Then
str3 = arrSplitStrings2(i)
Exit For
End If
Next i
End Sub