Hi Everyone
I have a huge database with Products, Quantities and Dates. The macro goes through this database (sheet "Data") and distribute them into the "Summary" sheet.
The loop is already created and it's running fine but it's taking too long (more than a hour) to cover the whole file. There are several loops in the same macro checking different data. What I'm trying to find another method to speed it up. Attached is a sample file with the loop and a sample data.
Any help will be very appreciated.
I will describe below a sample of a loop I'm using today.
Set ws1 = Worksheets("Data")
Set ws2 = Worksheets("Summary")
iDate = Date
fDate = iDate + 1
lRow = 2
Do While ws1.Cells(lRow, "A") <> ""
nRow = 11
Do While ws2.Cells(nRow, "B") <> ""
If ws2.Cells(nRow, "B") = ws1.Cells(lRow, "A") Then
If ws1.Cells(lRow, "B") < iDate Then
ws2.Cells(nRow, "C") = ws2.Cells(nRow, "C") + ws1.Cells(lRow, "D")
Else
For iCol = 4 To 10
If ws1.Cells(lRow, "B") >= iDate And ws1.Cells(lRow, "B") < fDate Then
ws2.Cells(nRow, iCol) = ws2.Cells(nRow, iCol) + ws1.Cells(lRow, "D")
End If
iDate = iDate + 1
fDate = fDate + 1
Next iCol
End If
End If
Loop
Loop
Bookmarks