Hi there,
I'm hoping you can help with an error? I'm getting error 9, subscript out of range for the very first if statement. The end goal is to be able to use the two "id" arrays to compare the matching values in the "finish" arrays to each other. The IDs are all unique and are consistent between the two arrays. I'd appreciate any advice you can give! Thank you. Here is the entirety of the applicable code:
Dim id1() As Variant
'Dim id1I As Interior
Dim id2() As Variant
'Dim id2I As Interior
Dim finish1() As Variant
'Dim finish1I As Interior
Dim finish2() As Variant
'Dim finish2I As Interior
Dim c As Variant, a As Variant
Set past = ThisWorkbook.Worksheets("Practice S 2")
Set present = ThisWorkbook.Worksheets("Practice S")
lastRow = past.Cells(Rows.Count, "D").End(xlUp).Row
id1 = past.Range("D2:D" & lastRow)
id2 = present.Range("D2:D" & lastRow)
finish1 = past.Range("I2:I" & lastRow)
finish2 = present.Range("I2:I" & lastRow)
For c = 1 To UBound(id1, 1)
Debug.Print id1(c, 1)
Next c
For c = 1 To UBound(finish1, 1)
Debug.Print finish1(c, 1)
Next c
For c = LBound(id1, 1) To UBound(id1, 1)
For a = LBound(id2, 1) To UBound(id2, 1)
If id1(c) = id2(a) Then ' And id1(c) <> "" Then
forecastFin = finish1(c)
MsgBox ("Matched ID: " & forecastFin)
'If (forecastFin) <= CDate(MeDate) And (forecastFin) >= CDate(MpDate) Then
' forecastFinCount = forecastFinCount + 1
'End If
End If
Next a
Next c
I'm hoping you can help with an error? I'm getting error 9, subscript out of range for the very first if statement. The end goal is to be able to use the two "id" arrays to compare the matching values in the "finish" arrays to each other. The IDs are all unique and are consistent between the two arrays. I'd appreciate any advice you can give! Thank you. Here is the entirety of the applicable code:
Dim id1() As Variant
'Dim id1I As Interior
Dim id2() As Variant
'Dim id2I As Interior
Dim finish1() As Variant
'Dim finish1I As Interior
Dim finish2() As Variant
'Dim finish2I As Interior
Dim c As Variant, a As Variant
Set past = ThisWorkbook.Worksheets("Practice S 2")
Set present = ThisWorkbook.Worksheets("Practice S")
lastRow = past.Cells(Rows.Count, "D").End(xlUp).Row
id1 = past.Range("D2:D" & lastRow)
id2 = present.Range("D2:D" & lastRow)
finish1 = past.Range("I2:I" & lastRow)
finish2 = present.Range("I2:I" & lastRow)
For c = 1 To UBound(id1, 1)
Debug.Print id1(c, 1)
Next c
For c = 1 To UBound(finish1, 1)
Debug.Print finish1(c, 1)
Next c
For c = LBound(id1, 1) To UBound(id1, 1)
For a = LBound(id2, 1) To UBound(id2, 1)
If id1(c) = id2(a) Then ' And id1(c) <> "" Then
forecastFin = finish1(c)
MsgBox ("Matched ID: " & forecastFin)
'If (forecastFin) <= CDate(MeDate) And (forecastFin) >= CDate(MpDate) Then
' forecastFinCount = forecastFinCount + 1
'End If
End If
Next a
Next c