E
ExcelMonkey
I am trying to return a value for "A" in my select case
below. Its a value extracted from an array using the
equivalent of an Index formual with a Match in side it.
however I am not sure how to use it on a 2D array where I
want to focus on specific columns.
I have an 2D array of Data that looks like this:
1 1
2 0
3 0
4 2
5 0
6 3
I want to be able to extract the values in column 1 based
on row identified by the values in column 2. The rows in
column 2 are set out below in my For Loop (X = 1 to 3).
I pass X to a second sub and within that sub I need to
return the row position of X in the array (column 2).
When X = 1, it is found in row 1 of column 2
When X = 2, it is found in row 4 of column 2
When X = 3, it is found in row 6 of column 2
I then use this row number in an index formula on column
1. Hence Index(column1 of array, row, column).
Effectively I am creating an index of column 1 using the
row value returned from a Match of X on column 2.
The entire routine that looks like this. The value I am
trying to calc is in the Select Case in Sub2
Sub1 ()
For Each sht in Workbook
For X = 1 to 3
Call Sub2(X)
Next
Next
Sub2 (A As Integer)
Select Case A
I don't know the proper syntax for calculating A!!!!!
A = Application.Index(Arraycol1,.Match(A,Arraycol2,0),1)
Case Is = 1
Code
Case Is = 2
Code
Case Is = 3
Code
Case Is = 4
Code
Case Is = 5
Code
Case Is = 6
Code
End Select
End Sub
Can anyone one guide me on this? Sorry for the maximum
detail. I tried to simplify it.
Thanks
below. Its a value extracted from an array using the
equivalent of an Index formual with a Match in side it.
however I am not sure how to use it on a 2D array where I
want to focus on specific columns.
I have an 2D array of Data that looks like this:
1 1
2 0
3 0
4 2
5 0
6 3
I want to be able to extract the values in column 1 based
on row identified by the values in column 2. The rows in
column 2 are set out below in my For Loop (X = 1 to 3).
I pass X to a second sub and within that sub I need to
return the row position of X in the array (column 2).
When X = 1, it is found in row 1 of column 2
When X = 2, it is found in row 4 of column 2
When X = 3, it is found in row 6 of column 2
I then use this row number in an index formula on column
1. Hence Index(column1 of array, row, column).
Effectively I am creating an index of column 1 using the
row value returned from a Match of X on column 2.
The entire routine that looks like this. The value I am
trying to calc is in the Select Case in Sub2
Sub1 ()
For Each sht in Workbook
For X = 1 to 3
Call Sub2(X)
Next
Next
Sub2 (A As Integer)
Select Case A
I don't know the proper syntax for calculating A!!!!!
A = Application.Index(Arraycol1,.Match(A,Arraycol2,0),1)
Case Is = 1
Code
Case Is = 2
Code
Case Is = 3
Code
Case Is = 4
Code
Case Is = 5
Code
Case Is = 6
Code
End Select
End Sub
Can anyone one guide me on this? Sorry for the maximum
detail. I tried to simplify it.
Thanks