View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Split Function gives rn-time error

Maybe you were looking for something like:

Option Explicit
Sub test()

Dim x As Variant
Dim txt As String
Dim iCtr As Long

txt = "abc;xyz;456m;9a6d"
x = Split(txt, ";")

For iCtr = LBound(x) To UBound(x)
MsgBox x(iCtr) & "--is element #: " & iCtr
Next iCtr

MsgBox Join(x, ";") & "--back together again!"

End Sub

davidm wrote:

The following code testing the usage of the SPLIT FUNCTION gives me a
run-time
error (on xl2003).

Sub test()

Dim x
Dim txt as String

txt = "abc;xyz;456m;9a6d"
x= Split(txt,";")

Msgbox x

End sub

What am I doing wrong? x is supposed to reurn [abc xyz 456m 9a6d].

David

--
davidm
------------------------------------------------------------------------
davidm's Profile: http://www.excelforum.com/member.php...o&userid=20645
View this thread: http://www.excelforum.com/showthread...hreadid=480974


--

Dave Peterson