Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Passing result of multiple split function results to 1 Array

I know I can use the split function on a string to return an array.

Array = Split(var2)

I have 8 string variables that I want to apply the split function to and I
then want to send all these elements into 1 Master Array. Do I still have to
create the 8 individual arrays as a middle step or can bypass this using some
sort of aggregation in brackets like:

MasterArray =
(Split(var1),Split(var2),Split(var3),Split(var4),S plit(var5),Split(var6),Split(var7),Split(var8))

Thanks

EM
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Passing result of multiple split function results to 1 Array

Maybe you could concatenate the 8 strings into one giant string (use the same
delimiter between strings as you use between fields).

Then split that giant string.

dim myBigString as string
dim s1 as string
dim s2 as string
'...
dim s8 as string
dim myArray as variant

myBigString = s1 & "," & s2 & "," & ... & "," & s8
myarray = split(mybigstring, ",")



ExcelMonkey wrote:

I know I can use the split function on a string to return an array.

Array = Split(var2)

I have 8 string variables that I want to apply the split function to and I
then want to send all these elements into 1 Master Array. Do I still have to
create the 8 individual arrays as a middle step or can bypass this using some
sort of aggregation in brackets like:

MasterArray =
(Split(var1),Split(var2),Split(var3),Split(var4),S plit(var5),Split(var6),Split(var7),Split(var8))

Thanks

EM


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 947
Default Passing result of multiple split function results to 1 Array

Here's one idea. I assume your delimiter is the Space character.

Sub Demo()
Dim m, s1, s2, s3
s1 = "a b c d"
s2 = "e f g h"
s3 = "i j k"
m = Split(Join(Array(s1, s2, s3)))
End Sub

--
HTH :)
Dana DeLouis
Windows XP & Excel 2007


"ExcelMonkey" wrote in message
...
I know I can use the split function on a string to return an array.

Array = Split(var2)

I have 8 string variables that I want to apply the split function to and I
then want to send all these elements into 1 Master Array. Do I still have
to
create the 8 individual arrays as a middle step or can bypass this using
some
sort of aggregation in brackets like:

MasterArray =
(Split(var1),Split(var2),Split(var3),Split(var4),S plit(var5),Split(var6),Split(var7),Split(var8))

Thanks

EM



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Passing result of multiple split function results to 1 Array

ExcelMonkey wrote:
I know I can use the split function on a string to return an array.

Array = Split(var2)

I have 8 string variables that I want to apply the split function to and I
then want to send all these elements into 1 Master Array. Do I still have to
create the 8 individual arrays as a middle step or can bypass this using some
sort of aggregation in brackets like:

MasterArray =
(Split(var1),Split(var2),Split(var3),Split(var4),S plit(var5),Split(var6),Split(var7),Split(var8))

Thanks

EM

I use Excel2002, so I don't have the Split function. But I suspect that
if the functions in the freely downloadable file at
http://home.pacbell.net/beban are available to your workbook, the
following will do what you are seeking:

MasterArray = MakeArray(Split(var1), Split(var2), . . .,Split(var8), 1)

If you want MasterArray to be 0-based rather than 1-based, change the 1
to 0. In either event, MasterArray will be one-dimensional.

Alan Beban
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Passing result of multiple split function results to 1 Array

Split was added in xl2k.

Alan Beban wrote:

ExcelMonkey wrote:
I know I can use the split function on a string to return an array.

Array = Split(var2)

I have 8 string variables that I want to apply the split function to and I
then want to send all these elements into 1 Master Array. Do I still have to
create the 8 individual arrays as a middle step or can bypass this using some
sort of aggregation in brackets like:

MasterArray =
(Split(var1),Split(var2),Split(var3),Split(var4),S plit(var5),Split(var6),Split(var7),Split(var8))

Thanks

EM

I use Excel2002, so I don't have the Split function. But I suspect that
if the functions in the freely downloadable file at
http://home.pacbell.net/beban are available to your workbook, the
following will do what you are seeking:

MasterArray = MakeArray(Split(var1), Split(var2), . . .,Split(var8), 1)

If you want MasterArray to be 0-based rather than 1-based, change the 1
to 0. In either event, MasterArray will be one-dimensional.

Alan Beban


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Passing result of multiple split function results to 1 Array

Dave Peterson wrote:
Split was added in xl2k.


Oh good! So I tested it.

If the functions in the freely downloadable file at
http://home.pacbell.net/beban are available to your workbook

MasterArray = MakeArray(Split(var1), Split(var2), . . .,Split(var8), 1)

If you want MasterArray to be 0-based rather than 1-based, change the 1
to 0. In either event, MasterArray will be one-dimensional.

Alan Beban
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
Passing Array Formula result to a variable in VBA (Leo) Leo Excel Programming 2 December 25th 07 06:22 AM
Passing indexed array value to VBA function [email protected] Excel Programming 7 August 9th 06 12:57 AM
split results to multiple worksheets Rich Excel Worksheet Functions 3 April 11th 05 07:51 PM
Passing array of strings from DLL function to VBA Jag Man Excel Programming 0 January 12th 04 10:09 PM
Passing array to a function GB[_3_] Excel Programming 3 October 21st 03 09:59 AM


All times are GMT +1. The time now is 12:47 PM.

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

About Us

"It's about Microsoft Excel"