Hi, I'm working on simple code to copy and paste certain rows from a list based on a corresponding list of values. (Specifically, one list contains extraneous rows of data, but I only want to copy/paste the matching rows). My code is:
But I'm getting an overflow error with in the Else: j = j + 1 line. Would appreciate if somebody could help me. Thanks!
[Edit: I guess a potential problem is that one of the rows in the first list (i) has no match in the second list (j), which could cause j to increase indefinitely?]
Code:
Sub Get_School_Data()
Dim i As Integer
Dim j As Integer
i = 7
j = 5
Do While Worksheets("College Bound").Cells(i, 2) <> ""
If Worksheets("PSSA").Cells(j, 2) = Worksheets("College Bound").Cells(i, 2) Then
Worksheets("College Bound").Range("D" & j).EntireRow.Copy Worksheets("College Bound").Rows(80)
i = i + 1
Else: j = j + 1
End If
Loop
End Sub
[Edit: I guess a potential problem is that one of the rows in the first list (i) has no match in the second list (j), which could cause j to increase indefinitely?]