I have a 2D array in the following format. (Unsure how to format this so it appears in a table format. The first and second columns are 1 character each and the 3rd columns is 2 characters)
a 1 aa
a 2 ab
b 1 ba
b 2 bb
c 1 ca
c 2 cb
d 1 da
d 2 db
e 1 ea
e 2 eb
f 1 fa
f 2 fb
I need to first search for "c" in the first column. If that is found, I need to search for "2" in the second and find the corresponding value in the 3rd. In this case, I finally need the value "cb".
Here is what I have so far but it isn't working correctly since I don't see the desired results
Public Sub Readinto_array()
Dim TheArray As Variant
Dim i As Long, j As Long, k As Long
Dim found As Boolean
TheArray = Range("G20:I31").Value
found = False
For i = LBound(TheArray) To UBound(TheArray)
For j = LBound(TheArray, 2) To UBound(TheArray, 2)
MsgBox TheArray(i, j)
If TheArray(i, j) <> "c" Then
Exit For
Else
If StrComp(TheArray(i, j + 1), "2", vbTextCompare) = 0 Then
MsgBox "found"
found = True
Exit For
End If
End If
Next j
If found Then
Exit For
End If
Next i
End Sub
