Can anyone help me speed up this code? It takes way too long to run
This program averages 7 worksheets from different workbooks cell by cell for column A2:A8761 (hours in a year), but essentially never finishes, I know I could use more ram, but I am afraid it wouldn't help that much, I currently have 2GB, the program usually stops around row 5000, but that is after about 10 minutes. Is there a way to speed this up?
Thanks!
Code:
Dim file As Integer, x As Integer, rw As Integer, cl As Integer
Dim fl As String
Dim count As Integer
Cells(1, 37).Select
fl = Dir("C:\(Path)" & "*.xls")
Do While Len(fl) > 0
ActiveCell.Formula = fl
ActiveCell.Offset(1, 0).Select
fl = Dir()
Loop
Cells(8, 37) = ""
x = Cells(Rows.count, 37).End(xlUp).Row
For cl = 1 To 7
For rw = 2 To 8761
For file = 1 To x
Cells(3, 36) = "='C:\(path)[" & Cells(file, 37) & "]Sheet1'!A" & rw & ""
Cells(2, 36) = Cells(2, 36) + Cells(3, 36)
Next file
Cells(rw, cl) = Cells(2, 36) / 7
Range("AJ2").Clear
Next rw
Next cl
This program averages 7 worksheets from different workbooks cell by cell for column A2:A8761 (hours in a year), but essentially never finishes, I know I could use more ram, but I am afraid it wouldn't help that much, I currently have 2GB, the program usually stops around row 5000, but that is after about 10 minutes. Is there a way to speed this up?
Thanks!
Last edited by a moderator: