PDA

View Full Version : Solved: Sum same cloumn and delete duplicated row



parscon
12-01-2012, 06:46 AM
I have some data on my Excel , I need a VBA code that first check the Column A and B and if the data on these column will be same sum their column C and delete the duplicate row .

patel
12-01-2012, 10:37 AM
attach a file with input table and output table

parscon
12-01-2012, 11:01 AM
I updated my excel file , now it has 2 sheet , sheet 1 is the original data and sheet 2 is the result of my request ,
explain again :
VBA will check column A and B and if there are same sum their column C and also merge the column d after that delete the duplicated rows .

patel
12-01-2012, 11:28 AM
Are Data in col A allready ordered ? if yes
Sub a()
arow = 2
Do While Cells(arow, 1).Text <> ""
If Cells(arow, 1).Text = Cells(arow - 1, 1).Text Then
Cells(arow - 1, 3) = Cells(arow - 1, 3) + Cells(arow, 3)
Cells(arow - 1, 4) = Cells(arow - 1, 4) & ", " & Cells(arow, 4)
Rows(arow).Delete
Else
arow = arow + 1
End If
Loop

End Sub

parscon
12-01-2012, 01:43 PM
Thank you but must check column A and B AND if they are same do this , now just check column A .

patel
12-02-2012, 12:22 AM
Sub a()
arow = 2
Do While Cells(arow, 1).Text <> ""
If Cells(arow, 1).Text = Cells(arow - 1, 1).Text And Cells(arow, 2).Text = Cells(arow - 1, 2).Text Then
Cells(arow - 1, 3) = Cells(arow - 1, 3) + Cells(arow, 3)
Cells(arow - 1, 4) = Cells(arow - 1, 4) & ", " & Cells(arow, 4)
Rows(arow).Delete
Else
arow = arow + 1
End If
Loop

parscon
12-02-2012, 04:14 AM
Thank you very much , it was a very big help for you . Really Thank you