ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Accessing a 'column' in a VB array (https://www.excelbanter.com/excel-programming/364208-accessing-column-vbulletin-array.html)

den1s

Accessing a 'column' in a VB array
 
In VB, how does one access an entire column or row. Let's say I have a
5x2 array and I would like to access all the data in the 1 column (i.e.

(1,1 2,1 3,1 4,1 5,1).

So given a variable defined as,


tempArray(1 To 2, 1 To 5) As Double


how could I access all the 1's column?


I know in Matlab I could use the command,


tempArray(:,1)


not sure the equivalent in Excel.


- Kwaj


jindon[_55_]

Accessing a 'column' in a VB array
 

den1s Wrote:
In VB, how does one access an entire column or row. Let's say I have a
5x2 array and I would like to access all the data in the 1 colum
(i.e.

(1,1 2,1 3,1 4,1 5,1).

So given a variable defined as,


tempArray(1 To 2, 1 To 5) As Double


how could I access all the 1's column?


I know in Matlab I could use the command,


tempArray(:,1)


not sure the equivalent in Excel.


- Kwaj

Try something like

Code
-------------------

Dim i As Integer
For i = LBound(tempArray,2) To UBound(tempArray,2)
MsgBox tempArray(2, i)
Next

-------------------

--
jindo
-----------------------------------------------------------------------
jindon's Profile: http://www.excelforum.com/member.php...fo&userid=1313
View this thread: http://www.excelforum.com/showthread.php?threadid=55173


Alan Beban

Accessing a 'column' in a VB array
 
den1s wrote:
In VB, how does one access an entire column or row. Let's say I have a
5x2 array and I would like to access all the data in the 1 column (i.e.

(1,1 2,1 3,1 4,1 5,1).

So given a variable defined as,


tempArray(1 To 2, 1 To 5) As Double


how could I access all the 1's column?


I know in Matlab I could use the command,


tempArray(:,1)


not sure the equivalent in Excel.


- Kwaj

Application.Index(tempArray, 0, 1)

Alan Beban


All times are GMT +1. The time now is 04:43 PM.

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