I am trying to create an array with project numbers. The code below loops through a list of programs within countries (in the program content review tab). For each program it switches to a tab with a list of projects (Project Summary Stats) and I want it to create an array with the project numbers so that in separate code I can call on it. The code below identifies the activeprogramnum correctly but spits out all kinds of strange project numbers. Help!
Sub test_array()
Dim ActiveProgramNum
Sheets("ProgramContentReview").Select
Range("b2").Select ' country
Do Until IsEmpty(ActiveCell)
Dim ProjectNumArray(10)
Dim l
l = 0
If (Sheets("Introduction").Range("A15").Value & " ") = ActiveCell.Value Then ' This identifies the country
ActiveProgramNum = ActiveCell.Offset(0, 2)
Sheets("ProjectSummaryStats").Select
' Select cell A2, *first line of data*.
Range("D2").Select
Do Until IsEmpty(ActiveCell) ' loop through projects (at program level)
If ActiveProgramNum = ActiveCell.Value Then
ProjectNumArray(l) = ActiveCell.Offset(0, 2).Value ' this is the column with the project numbers
l = l + 1
MsgBox (ActiveProgramNum)
MsgBox (ProjectNumArray(l))
End If
ActiveCell.Offset(1, 0).Select
Loop
End If
Sheets("ProgramContentReview").Select
ActiveCell.Offset(1, 0).Select
Loop
End Sub