Hiya,
Arrays are new to me and I'm trying to look at 3 columns and do some comparisons. :huh:
I want to check in the ManagerArr() (assigned to a range in 1 column) and if the value is zero then compare the ClientArr() values and those in the MainframeArr() or else, compare the ManagerArr() to the cells in MainframeArr().
Phew.
Currently I've tried to do it like this:
But I get a type mismatch when it gets to the ReDim and also I'm concerned cos I don't know if you can really nest for For Next Loop(s) like that, but it won't get that far anyway for me to find out.
Can someone out there explain how to approach this sort of thing?
Many thanks in advance!
Arrays are new to me and I'm trying to look at 3 columns and do some comparisons. :huh:
I want to check in the ManagerArr() (assigned to a range in 1 column) and if the value is zero then compare the ClientArr() values and those in the MainframeArr() or else, compare the ManagerArr() to the cells in MainframeArr().
Phew.
Currently I've tried to do it like this:
Code:
Public Sub TryArrays()
Dim LastRow As Long
Dim LastCell As Range
Dim ClientArr As Variant
Dim ManagerArr As Variant
Dim MainframeArr As Variant
Dim clRange As String
Dim mfRange As String
Dim acmRange As String
Set LastCell = Range("A1").SpecialCells(xlCellTypeLastCell)
LastRow = LastCell.Row
clRange = "AG" & LastRow
acmRange = "AI" & LastRow
mfRange = "AH" & LastRow
ReDim ClientArr(Range("AG2"), clRange) As Variant
ReDim ManagerArr(Range("AI2"), acmRange) As Variant
ReDim MainframeArr(Range("AH2"), mfRange) As Variant
For i = LBound(ClientArr()) To UBound(ManagerArr())
If ManagerArr(i) = 0 Then
For x = LBound(ClientArr()) To UBound(MainframeArr())
If ClientArr(x) = MainframeArr(x) Then
Range("AK" & x).FormulaR1C1 = "MATCH!"
Else
Range("AK" & x).FormulaR1C1 = "NO MATCH!"
End If
Next x
ElseIf ManagerArr(i) > 0 Then
For y = LBound(ClientArr()) To UBound(ManagerArr())
If ClientArr(y) = ManagerArr(y) Then
Range("AK" & y).FormulaR1C1 = "MATCH!"
Else
Range("AK" & y).FormulaR1C1 = "NO MATCH!"
End If
Next y
End If
Next i
End Sub
But I get a type mismatch when it gets to the ReDim and also I'm concerned cos I don't know if you can really nest for For Next Loop(s) like that, but it won't get that far anyway for me to find out.
Can someone out there explain how to approach this sort of thing?
Many thanks in advance!