![]() |
Split Function gives rn-time error
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 |
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 |
Split Function gives rn-time error
Thanks Dave for this other dimension viz using the JOIN FUNCTION as complement to reverse the process. Your example as well as Leith Ross' settles the way the SPLIT is used. It is a pity, as I remarked earlier that as a function, the Split should have very low utility rating. I would appear that for what it accomplishes, there are probably handful of better ways to explore. Little wonder, the Help file note waxed darn little about it. The good is that it broadens the choices w have, anyhow (<g). Thanks again, Dave -- david ----------------------------------------------------------------------- davidm's Profile: http://www.excelforum.com/member.php...fo&userid=2064 View this thread: http://www.excelforum.com/showthread.php?threadid=48172 |
Split Function gives rn-time error
If you search google groups for split (or split97, split was added with xl2k),
you'll see some real-life examples of how useful spit can be. I think most users of xl2k+ are happy it's there. davidm wrote: Thanks Dave for this other dimension viz using the JOIN FUNCTION as a complement to reverse the process. Your example as well as Leith Ross's settles the way the SPLIT is used. It is a pity, as I remarked earlier, that as a function, the Split should have very low utility rating. It would appear that for what it accomplishes, there are probably a handful of better ways to explore. Little wonder, the Help file notes waxed darn little about it. The good is that it broadens the choices we have, anyhow (<g). Thanks again, Dave. -- davidm ------------------------------------------------------------------------ davidm's Profile: http://www.excelforum.com/member.php...o&userid=20645 View this thread: http://www.excelforum.com/showthread...hreadid=481725 -- Dave Peterson |
All times are GMT +1. The time now is 05:14 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com