I'm getting an out of memory error on the following block of code. Does anyone see an obvious reason why?
Edited the code to show entire block. eventually this will loop through a directory, but until working I'll only look at one file.
Sub Get_BT_Data()
Dim fNameAndPath, data As Variant
Dim j, c, r As Integer
fNameAndPath = Application.GetOpenFilename(FileFilter:="Excel Files (*.XLSM), *.XLSM", Title:="Select File To Be Opened")
If fNameAndPath = False Then Exit Sub
Workbooks.Open Filename:=fNameAndPath
Sheets("Summary For CDP").Activate
j = Range("A2").Value
c = Range("B2").Value
data = Range("DataRay")
ThisWorkbook.Activate
r = Cells(7, 4).End(xlDown).Row
For i = 7 To r
If Cells(i, 4).Value = j Then
If Cells(i, 4).Offset(0, 1).Value = c Then
Cells(i, 4).Offset(0, 3).Value = data(9, 20)
Cells(i, 4).Offset(0, 4).Value = data(22, 22)
Cells(i, 4).Offset(0, 7).Value = data(2, 20)
Cells(i, 4).Offset(0, 8).Value = data(15, 22)
Cells(i, 4).Offset(0, 10).Value = data(5, 20)
Cells(i, 4).Offset(0, 11).Value = data(18, 22)
Cells(i, 4).Offset(0, 13).Value = data(3, 22)
Cells(i, 4).Offset(0, 14).Value = data(16, 22)
Cells(i, 4).Offset(0, 16).Value = data(4, 20) + data(6, 20)
Cells(i, 4).Offset(0, 17).Value = data(17, 22) + data(19, 22)
Cells(i, 4).Offset(0, 19).Value = data(7, 20)
Cells(i, 4).Offset(0, 20).Value = data(20, 22)
Else
If i = r Then
Cells(7, 4).End(xlDown).Offset(-2, 0).EntireRow.Insert
Else
End If
End If
Else
End If
Next i
End Sub
r???