LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Extracting 3 Arrays from 1 Array

That is an array of arrays, something like

myArray = Array(Array("A", "B", "C"), _
Array("D", "E", "F"), _
Array("G", "H", "I"))

although these are single dimension arrays

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"p45cal" wrote in message
...
I get errors with the likes of
UBound(vtData(0, 0), 1)
and
vtData(0, 0)(x, 0)

Let's have the code that creates vtData (or vtData(0,0) from Bloomberg.

--
p45cal


"JingleRock" wrote:

On Aug 22, 9:43 pm, "Dana DeLouis" wrote:
I want to create 3 child arrays (one for each column)
Do I need to use WorksheetFunction.Transpose?

Hi. In "general", one way is to use Transpose.
Any ideas here that can help?

Sub Demo()
Dim m As Variant 'Matrix
Dim v As Variant 'Vector
Dim s As String 'String
Dim c As Long 'Column
Const All As Long = 0 'All Rows or Columns

m = [A1:C5].Value
With WorksheetFunction
For c = 1 To 3
v = .Index(m, All, c)
v = .Transpose(v)
s = Join(v, ",")
Debug.Print s
Next c
End With
End Sub

ActiveSheet.Range(Cells(8, 1), Cells(8 + UB1, 3)) = vtData(0, 0),

I like to use "Resize," as I find it easier to read / understand.

Sub Demo2()
Dim m As Variant 'Matrix
m = [A1:C5].Value

[A10].Resize(5, 3) = m
End Sub

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

"JingleRock" wrote in message

ups.com...



I have a 2-dimensional array [vtData(0, 0)] that is Dimensioned (Dim
vtData As Variant); its Lbound for each dimension is 0 and its UBound
for dimension1 is 4 and its UBound for dimension2 is 2; therefore, 15
elements. (This array is imported into my VBA Code from Bloomberg.)

I do NOT want to paste this array into a worksheet; however, in
design
mode only, I am using the following to do exactly that (and it
works):

ActiveSheet.Range(Cells(8, 1), Cells(8 + UB1, 3)) = vtData(0, 0),
where UB1 is UBound for dimension1.

OK, I want to create 3 child arrays (one for each column) from the
parent array. (My objective is to connect the individual elements for
each column into one string, using a delimiter, and then paste that
string into a specified cell in my worksheet.) This is my non-working
code:

Dim Col_One As Variant, x As Integer
ReDim Col_One(UB1 + 1)
For x = 0 To UB1
Col_One(x) = vtData(x, 0)
Next x
When stepping-thru my code:
when x = 0, there are no errors;
when x = 1, I get the dreaded 'subscript out of range' error.

Do I need to use WorksheetFunction.Transpose?



Thanks Bob, again, p45cal, and Dana. I learned a lot from your posts.

my application -- I am hereby providing add'l info. I was using
static arrays at first, but I now (with the benefit of what I have
learned) must use dynamic ones (actually, the number of columns is a
constant) as my application requires.

I posted (most of) the code below in Msg #3; I am flabbergasted that
this works. Can anyone explain why?

Dim vtData As Variant
Dim Col_Array As Variant, x As Integer, UB1 As Integer
vtData = Bloomberg download code (imports variable # of rows, 3
columns)
' above data -- Col 1 is all dates; Col 2 is all prices;
Col 3 is all $ amounts
UB1 = UBound(vtData(0, 0), 1)
ReDim Col_Array(UB1 + 1)
For x = 0 To UB1
'THIS IS FIRST COLUMN (with Dimension2 Index = 0)
Col_Array(x) = vtData(0, 0)(x, 0)
Next x

I am using the same ReDim stmt and the same Col_Array(x) name for Col
2 and for Col 3.

JingleRock







 
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
How do you create an Array of Arrays? NickHK Excel Programming 0 December 22nd 06 02:03 AM
How do you create an Array of Arrays? Arvi Laanemets Excel Programming 0 December 21st 06 06:35 PM
array of arrays stored in Name: POSSIBLE? [email protected][_2_] Excel Programming 1 December 21st 04 10:55 PM
Array of Arrays in VBA Peter[_49_] Excel Programming 0 November 9th 04 09:50 PM
Extracting sub arrays from a 2-D VBA array Alan Beban[_2_] Excel Programming 7 August 16th 04 09:50 PM


All times are GMT +1. The time now is 06:44 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"