Reputation: 2643
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
Upvotes: 2
Views: 9675
Reputation: 28530
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.Split
resolved the reference confusion, because you're then telling it to use the Split method in the VBA namespace.
Upvotes: 8