I am getting the subscript out of range message for my VBA code within excel. Can anyone help me figure out where I went wrong in my code?
Private Sub HW2_2()
Dim FileNum As Integer
Dim DataLine As String
Dim col() As String
Dim MyArray(1 To 50, 1 To 15) As Integer
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim Maximum As Double
FileNum = FreeFile()
Open "C:\Users\slade\Desktop\Spring 2018\ABE 316\HW2\HW02data.txt" For Input As #FileNum
While Not EOF(FileNum)
For i = 1 To 50
For j = 1 To 15
Line Input #FileNum , DataLine
col = Split(DataLine)
MyArray(i, j) = col(1)
Cells(i, j).Value = col(1)
Next j
Next i
Wend
Cells(52, 1).Value = "Batch no."
Cells(52, 3).Value = "Max Value"
k = 52
For i = 1 To 50
Maximum = Cells(i, 1).Value
For j = 1 To 15
If (Maximum < Cells(i, j).Value) Then
Maximum = Cells(i, j).Value
End If
Next j
Cells(k + i, 1).Value = i
Cells(k + i, 2).Value = Maximum
Next i
End Sub
Private Sub HW2_2()
Dim FileNum As Integer
Dim DataLine As String
Dim col() As String
Dim MyArray(1 To 50, 1 To 15) As Integer
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim Maximum As Double
FileNum = FreeFile()
Open "C:\Users\slade\Desktop\Spring 2018\ABE 316\HW2\HW02data.txt" For Input As #FileNum
While Not EOF(FileNum)
For i = 1 To 50
For j = 1 To 15
Line Input #FileNum , DataLine
col = Split(DataLine)
MyArray(i, j) = col(1)
Cells(i, j).Value = col(1)
Next j
Next i
Wend
Cells(52, 1).Value = "Batch no."
Cells(52, 3).Value = "Max Value"
k = 52
For i = 1 To 50
Maximum = Cells(i, 1).Value
For j = 1 To 15
If (Maximum < Cells(i, j).Value) Then
Maximum = Cells(i, j).Value
End If
Next j
Cells(k + i, 1).Value = i
Cells(k + i, 2).Value = Maximum
Next i
End Sub