Hi,
I want to check if there is an alternative code (shorter) for the code starting from the line
to
This loop matches combination of values from two different worksheets. I store all information in an array and perform the loop inside the array. Once it finds a match, the macro will check if the difference in number of days between these matched transactions should not be more than the range set by the user. (e.g., if the amount of transaction A matched with Transaction D, the difference in days between these two transactions should not be over 3 (range set by the user).
below refers to the "Day" (e.g, 10) stored in the array.
I want to check if there is an alternative code (shorter) for the code starting from the line
VBA Code:
[B] If Abs(r1D(h) - r1D(j)) <= DaySet _[/B]
VBA Code:
[B] And Abs(r1D(q) - r2D(l)) <= DaySet Then[/B]
This loop matches combination of values from two different worksheets. I store all information in an array and perform the loop inside the array. Once it finds a match, the macro will check if the difference in number of days between these matched transactions should not be more than the range set by the user. (e.g., if the amount of transaction A matched with Transaction D, the difference in days between these two transactions should not be over 3 (range set by the user).
VBA Code:
r1D
VBA Code:
'5:3 Matching
For h = 0 To uR1
For i = 0 To uR2
For j = h + 1 To uR1
For o = j + 1 To uR1
For p = o + 1 To uR1
For q = p + 1 To uR1
For k = i + 1 To uR2
For l = k + 1 To uR2
If r1V(h) > 0 And r1V(j) > 0 And r1V(o) > 0 And r1V(p) > 0 And r1V(q) > 0 And r2V(i) > 0 And r2V(k) > 0 And r2V(l) > 0 Then
If r1V(h) + r1V(j) + r1V(o) + r1V(p) + r1V(q) = r2V(i) + r2V(k) + r2V(l) Then
[B] If Abs(r1D(h) - r1D(j)) <= DaySet _
And Abs(r1D(h) - r1D(o)) <= DaySet _
And Abs(r1D(h) - r1D(p)) <= DaySet _
And Abs(r1D(h) - r1D(q)) <= DaySet _
And Abs(r1D(h) - r2D(i)) <= DaySet _
And Abs(r1D(h) - r2D(k)) <= DaySet _
And Abs(r1D(h) - r2D(l)) <= DaySet _
And Abs(r1D(j) - r1D(o)) <= DaySet _
And Abs(r1D(j) - r1D(p)) <= DaySet _
And Abs(r1D(j) - r1D(q)) <= DaySet _
And Abs(r1D(j) - r2D(i)) <= DaySet _
And Abs(r1D(j) - r2D(k)) <= DaySet _
And Abs(r1D(j) - r2D(l)) <= DaySet _
And Abs(r1D(o) - r1D(p)) <= DaySet _
And Abs(r1D(o) - r1D(q)) <= DaySet _
And Abs(r1D(o) - r2D(i)) <= DaySet _
And Abs(r1D(o) - r2D(k)) <= DaySet _
And Abs(r1D(o) - r2D(l)) <= DaySet _
And Abs(r1D(p) - r1D(q)) <= DaySet _
And Abs(r1D(p) - r2D(i)) <= DaySet _
And Abs(r1D(p) - r2D(k)) <= DaySet _
And Abs(r1D(p) - r2D(l)) <= DaySet _
And Abs(r1D(q) - r2D(i)) <= DaySet _
And Abs(r1D(q) - r2D(k)) <= DaySet _
And Abs(r1D(q) - r2D(l)) <= DaySet Then[/B]
rpt1.Range(r1A(h)).Interior.ColorIndex = 26
rpt1.Range(r1A(j)).Interior.ColorIndex = 26
rpt1.Range(r1A(o)).Interior.ColorIndex = 26
rpt1.Range(r1A(p)).Interior.ColorIndex = 26
rpt1.Range(r1A(q)).Interior.ColorIndex = 26
rpt2.Range(r2A(i)).Interior.ColorIndex = 26
rpt2.Range(r2A(k)).Interior.ColorIndex = 26
rpt2.Range(r2A(l)).Interior.ColorIndex = 26
r1V(h) = 0: r1V(j) = 0: r1V(o) = 0: r1V(p) = 0: r1V(q) = 0: r2V(i) = 0: r2V(k) = 0: r2V(l) = 0
If IsEmpty(sl) = False Then
rpt1.Cells(E_N(r1A(q)), sl).Value _
= "=" & "SUM(" & r1A(h) & "," & r1A(j) & "," & r1A(o) & "," & r1A(p) & "," & r1A(q) & ")" & "-" _
& "SUM('" & sn & "'!" & r2A(i) & ",'" & sn & "'!" & r2A(k) & ",'" & sn & "'!" & r2A(l) & ")"
rpt1.Cells(E_N(r1A(q)), sl).Interior.ColorIndex = 26
End If
End If
End If
End If
Next l
Next k
Next q
Next p
Next o
Next j
Next i
Next h