ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to split a string and return array (https://www.excelbanter.com/excel-programming/348078-how-split-string-return-array.html)

xiang[_9_]

how to split a string and return array
 

VBA code question:
how can I use split function to break a string and then retun th
results to array?

for example:
a string: Prince William, Manassas + Manassa
Park,[51942]
separator:comma , and plus sign +
results would be something like :
Myarray = (Prince William, Manassas, Manassas Park,[51942])
I think I have to Trim each element in Myarray before buildin
Myarray.

since the string will change, the upperbound of Myarray will chang
also.

any help or idea will be appreciated!!
thanks for any respons

--
xian
-----------------------------------------------------------------------
xiang's Profile: http://www.excelforum.com/member.php...fo&userid=2948
View this thread: http://www.excelforum.com/showthread.php?threadid=49333


Bob Phillips[_6_]

how to split a string and return array
 
Dim sTest As String
Dim aParts
sTest = "Prince William, Manassas + Manassas Park,[5192]"
aParts = Split(Replace(sTest, "+", ","), ",")


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"xiang" wrote in
message ...

VBA code question:
how can I use split function to break a string and then retun the
results to array?

for example:
a string: Prince William, Manassas + Manassas
Park,[51942]
separator:comma , and plus sign +
results would be something like :
Myarray = (Prince William, Manassas, Manassas Park,[51942])
I think I have to Trim each element in Myarray before building
Myarray.

since the string will change, the upperbound of Myarray will change
also.

any help or idea will be appreciated!!
thanks for any response


--
xiang
------------------------------------------------------------------------
xiang's Profile:

http://www.excelforum.com/member.php...o&userid=29489
View this thread: http://www.excelforum.com/showthread...hreadid=493338





All times are GMT +1. The time now is 01:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com