Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
freeze and split at the same time? Betty11 Excel Discussion (Misc queries) 2 May 21st 23 03:42 AM
Insert Function next to formula bar gives Run-time Error '50290' Nick Excel Discussion (Misc queries) 0 July 7th 08 03:41 PM
Worksheet function match - run time error Sajit Excel Worksheet Functions 3 July 8th 07 10:30 PM
Split Date and Time Cell Beamers Excel Discussion (Misc queries) 2 May 19th 06 07:25 PM
Split date and time Warsteiner Excel Discussion (Misc queries) 2 December 8th 05 10:10 PM


All times are GMT +1. The time now is 07:43 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"