2016-08-16 43 views
-1

我需要Excel VBA的一些幫助。基於2個單元的標準的循環SUM

我有3列數據W,X,Y:

What I have

最終結果是總結所有的X和Y具有相同的價值,並得到這樣的事情到W列更改值:

What needs to happen

+1

這會讓你開始:http://stackoverflow.com/questions/36821985/how-to-combine-duplicate-rows-and-sum-the-values-3-column-in-excel –

回答

1

得到它的工作:d

Sub Sort01() 

    lRow = 2 
    Do While (Cells(lRow, 23) <> "") 

    ItemRow1 = Cells(lRow, "Y") 
    ItemRow2 = Cells(lRow + 1, "Y") 

    lengthRow1 = Cells(lRow, "X") 
    lengthRow2 = Cells(lRow + 1, "X") 

    If ((ItemRow1 = ItemRow2) And (lengthRow1 = lengthRow2)) Then 
     Cells(lRow, "W") = Cells(lRow, "W") + Cells(lRow + 1, "W") 
     Rows(lRow + 1).Delete 

    Else 
     lRow = lRow + 1 
    End If 
Loop 
End sub 
+0

嗨dzunaa - 唐'忘記接受你的答案。發佈答案後48小時內可能會有這種情況。 –