Trying to check column one for a value (column in the multidimensional array that is) and if it matches sort another column for the value that matches that row.
I think I am doing this wrong, but this is the first time I am messing with multidimensional arrays.
Would I need to use UBound and LBound in each for loop to tell it what colum to look through?
I am def interested in learning the best practice method for using this in the future, aside from just an answer/solution tot he current issue.
Code:
Private Sub ThisStuff()
Dim CoaAmt As Long
Dim COAArray(3, 2)
Dim ThisValue As String
Dim AnotherValue As String
AnotherValue = "Bananas"
ThisValue = "Apples"
COAArray(0, 0) = "Apples"
COAArray(1, 0) = "Oranges"
COAArray(2, 0) = "Peaches"
COAArray(3, 0) = "Pomegranets"
COAArray(0, 1) = 498
COAArray(0, 1) = 505
COAArray(1, 1) = 564
COAArray(1, 2) = 556
COAArray(2, 1) = 570
COAArray(2, 2) = 573
COAArray(3, 1) = 742
COAArray(3, 2) = 750
If AnotherValue = "Bananas" Then
For i = COAArray(0, 0) To COAArray(3, 0)
For j = COAArray(1, 0) To COAArray(3, 2)
If COAArray(i, j) = ThisValue Then CoaAmt = COAArray(i, j)
Next j
Next i
End If
MsgBox ("The value of CoaAmt is " & CoaAmt)
End Sub