I have written a macro in order to check booking and remaining stock status. i have over 4000 cases which i want to check another data containing +4000 cases as well.
the macro is too slow who take over 20 sec for every case. kindly gimme a idea so that i can boost this macro to save time.
the macro is too slow who take over 20 sec for every case. kindly gimme a idea so that i can boost this macro to save time.
Code:
Sub remaining_stock()
Dim i As Long, c As Long, i1 As Long, c1 As Long
Dim qly As String
Dim qly1 As String
Dim shd As String
Dim shd1 As String
Dim qty As Double
Dim qty1 As Double
Dim qtyR As Double
c = Sheets("WH STOCK").Cells(Sheets("WH STOCK").Rows.Count, "a").End(xlUp).Row
c1 = Sheets("Bookings").Cells(Sheets("Bookings").Rows.Count, "a").End(xlUp).Row
For i = 2 To c
For i1 = 2 To c1
Application.StatusBar = i & " Cases out of " & c & " Bookings " & i1 & " Cases out of " & c1
qly = Worksheets("WH STOCK").Range("a" & i).Value
qly1 = Worksheets("Bookings").Range("a" & i1).Value
shd = Worksheets("WH STOCK").Range("b" & i).Value
shd1 = Worksheets("Bookings").Range("b" & i1).Value
qty = Worksheets("WH STOCK").Range("c" & i).Value
qty1 = Worksheets("Bookings").Range("c" & i1).Value
qtyR = Worksheets("WH STOCK").Range("D" & i1).Value
If qly = qly1 And shd = shd1 Then
Worksheets("WH STOCK").Range("d" & i).Value = qty1
End If
Worksheets("WH STOCK").Range("E" & i).Value = qty - Worksheets("WH STOCK").Range("D" & i).Value
If Worksheets("WH STOCK").Range("e" & i).Value < 0 Then
Worksheets("WH STOCK").Range("f" & i).Value = "Overbookings"
End If
If Worksheets("WH STOCK").Range("e" & i).Value = 0 Then
Worksheets("WH STOCK").Range("f" & i).Value = "Stock Finished"
End If
Next
Next
End Sub
Last edited by a moderator: