PDA

View Full Version : VBA Macros Help



yapmadhu
10-29-2008, 04:23 AM
Hai

I am New to VB Macros . I want to Check the Duplicate Value in the Excel Value Using Macro VB editor

Eg:

If the 1 St Row Contains Name as " VB" and the Value For Vb is 30 ( Name in the 1 St Column and Value in the 3 rd Column) and
2 nd Row Contains the Same Name "VB" and the Value for this is 20. (Name in the 1 st Column and Value in the 3rd Column)

I want to Remove the Duplicate Name and I want the output like this

VB and the Value is 50 (30+20)

Can Anyone Tell How can I Get this? Can AnyOne Send me the Code for Adding the Value After Checks the Duplicate Name

Thanks in Advance

Bob Phillips
10-29-2008, 04:57 AM
Public Sub ProcessData()
Dim LastRow As Long
Dim iRow As Long
Dim i As Long

With ActiveSheet

LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = LastRow To 1 Step -1

iRow = Application.Match(.Cells(i, "A").Value, .Columns(1), 0)
If iRow <> i Then

.Cells(iRow, "C").Value = .Cells(iRow, "C").Value + .Cells(i, "C").Value
.Rows(i).Delete
End If
Next i
End With

End Sub

yapmadhu
10-29-2008, 05:03 AM
Can I have Ur Mail ID?