Declaring one bidimensinal Array

A

Andoni

Hi!
And Thanks in advance!

I would like to have this array, kind of:
MyArray=Array(1,5;2,3;5,4;6,6;10,7)
this is just one example.
I am trying to get one array having the X and Y values of a differen
cells.


* * *

how can i doing this
MyArray(1).select
and keep selected the Range("P2") cell if Activecell is [A1]


Many thanks
PS at the moment i am doing this:
MyArray = Array(1, 5, 2, 3, 5, 4, 6, 6, 10, 7)
For X = 0 To 9
ActiveCell.Offset(MyArray(X), MyArray(X
1)).interior.colorindex=3 'just example
Debug.Print ActiveCell.Address
X = X + 1
Next
 
S

SunTzuComm

You could try doing it this way.

Sub Arrays_Test()
Dim lngCell(1 To 5, 1 To 2) As Long
Dim lngX As Long

lngCell(1, 1) = 1
lngCell(1, 2) = 5
lngCell(2, 1) = 2
lngCell(2, 2) = 3
lngCell(3, 1) = 5
lngCell(3, 2) = 4
lngCell(4, 1) = 6
lngCell(4, 2) = 6
lngCell(5, 1) = 10
lngCell(5, 2) = 7

For lngX = 1 To 5
With ActiveSheet.Cells(lngCell(lngX, 1), lngCell(lngX, 2))
Debug.Print .Address
End With
Next lngX
End Sub

This routine gives the following results. It doesn't change the currently
selected cell.

$E$1
$C$2
$D$5
$F$6
$G$10

Regards,
Wes
 
T

Tom Ogilvy

for a small number of elements

MyArray = Evaluate("{" & "1, 5; 2, 3; 5, 4; 6, 6; 10, 7" & "}")

this will give a 1x5, 1x2 array

from the immediate window:

MyArray = Evaluate("{" & "1, 5; 2, 3; 5, 4; 6, 6; 10, 7" & "}")
? lbound(myarray,1), ubound(myarray,1)
1 5
? lbound(myarray,2), ubound(myarray,2)
1 2
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top