Hello Experts,
I have a workbook with 2 sheets.
I request your help with a VBA macro in Sheet1 to calculate totals in case the Sales and Purchases for an item are equal.
The sample output should be as in Sheet2.
Thanks in advance.
Hello Experts,
I have a workbook with 2 sheets.
I request your help with a VBA macro in Sheet1 to calculate totals in case the Sales and Purchases for an item are equal.
The sample output should be as in Sheet2.
Thanks in advance.
Sub KedTest() Dim lr As Long, rw As Long, p As Long, s As Long, t As Double lr = Cells(Rows.Count, 1).End(xlUp).Row For rw = 2 To lr t = 0 p = 0 s = 0 Do Until Cells(rw, 1) = "" Cells(rw, 1).Select If Cells(rw, 2) = "Sales" Then s = s + Cells(rw, 4) If Cells(rw, 2) = "Purchase" Then p = p + Cells(rw, 4) t = t + Cells(rw, 6) rw = rw + 1 Loop If s = p Then Cells(rw, 6) = t Next End Sub
Semper in excretia sumus; solum profundum variat.
Hello paulked,
Thanks a lot for your help.