Playing with excel and came up with this error
Sub Split()
Dim txt As String
Dim x As Variant
txt = Sheets("Raw").Cells(2, 2).Value
MsgBox (txt)
x = Split(txt, ",")
For Each i In x
MsgBox (i)
Next
Give me an error of two many arguments for the split function
however
Sub Split()
Dim txt As String
Dim x As Variant
txt = Sheets("Raw").Cells(2, 2).Value
MsgBox (txt)
x = VBA.Split(txt, ",")
For Each i In x
MsgBox (i)
Next
works just fine?
So whats going on, I am sure i have used split before with out needing the vba. prefix?
Cheers
Aaron
Not real familiar with Excel VBA, but looking at the code snippet you posted I think the VBA interpreter may have gotten confused.
You have
Sub Split(), and the code that follows is, I assume, for that function?When it tried to execute
Split(txt, ","), it most likely thought you were referring to your Split function, which takes no arguments, yet you were passing in two.Using
VBA.Splitresolved the reference confusion, because you’re then telling it to use the Split method in the VBA namespace.