I can't understand what is wrong with the below program. It executes but returns values of (497) for all variables in the array. Help is appreciated.
Sub Search_PC_Num()
Dim SCRAP(4, 1 To 12) As Double
Do While (Selection.Value <> "")
For m = 1 To 12
VCELL = ActiveCell.Value
ActiveCell.Offset(0, 1).Select
MCELL = Int(Month(ActiveCell.Value))
If VCELL = "STR" Then
ActiveCell.Offset(0, 17).Select
x = ActiveCell.Value
SCRAP(0, m) = SCRAP(0, m) + x
ActiveCell.Offset(1, -18).Select
End If
If VCELL = "GRV" Then
ActiveCell.Offset(0, 17).Select
x = ActiveCell.Value
SCRAP(1, m) = SCRAP(1, m) + x
ActiveCell.Offset(1, -18).Select
End If
If VCELL = "s791" Then
ActiveCell.Offset(0, 17).Select
x = ActiveCell.Value
SCRAP(2, m) = SCRAP(2, m) + x
ActiveCell.Offset(1, -18).Select
End If
If VCELL = "PLX" Then
ActiveCell.Offset(0, 17).Select
x = ActiveCell.Value
SCRAP(3, m) = SCRAP(3, m) + x
ActiveCell.Offset(1, -18).Select
End If
If VCELL = "VICPR" Then
ActiveCell.Offset(0, 17).Select
x = ActiveCell.Value
SCRAP(4, m) = SCRAP(4, m) + x
ActiveCell.Offset(1, -18).Select
End If
Next m
Loop
Sheets("Scrap Rates").Select
Range("D30:O34").FormulaArray = SCRAP(4, 11)
End Sub
Sub Search_PC_Num()
Dim SCRAP(4, 1 To 12) As Double
Do While (Selection.Value <> "")
For m = 1 To 12
VCELL = ActiveCell.Value
ActiveCell.Offset(0, 1).Select
MCELL = Int(Month(ActiveCell.Value))
If VCELL = "STR" Then
ActiveCell.Offset(0, 17).Select
x = ActiveCell.Value
SCRAP(0, m) = SCRAP(0, m) + x
ActiveCell.Offset(1, -18).Select
End If
If VCELL = "GRV" Then
ActiveCell.Offset(0, 17).Select
x = ActiveCell.Value
SCRAP(1, m) = SCRAP(1, m) + x
ActiveCell.Offset(1, -18).Select
End If
If VCELL = "s791" Then
ActiveCell.Offset(0, 17).Select
x = ActiveCell.Value
SCRAP(2, m) = SCRAP(2, m) + x
ActiveCell.Offset(1, -18).Select
End If
If VCELL = "PLX" Then
ActiveCell.Offset(0, 17).Select
x = ActiveCell.Value
SCRAP(3, m) = SCRAP(3, m) + x
ActiveCell.Offset(1, -18).Select
End If
If VCELL = "VICPR" Then
ActiveCell.Offset(0, 17).Select
x = ActiveCell.Value
SCRAP(4, m) = SCRAP(4, m) + x
ActiveCell.Offset(1, -18).Select
End If
Next m
Loop
Sheets("Scrap Rates").Select
Range("D30:O34").FormulaArray = SCRAP(4, 11)
End Sub