Add Like

pastorkc

Board Regular
Joined
Jan 29, 2020
Messages
125
Office Version
  1. 2010
Platform
  1. Windows
Is there a code I can run to look down Column A and Column B then add those to lines together and place the value in Column D and delete the second line?

Transit Invoice Sheet.xlsm
ABCD
1Check #Vendor NameAccount DescriptionDirect To Program
221861Logical, LLCProfessional Services Transit8.00
3920Brand WiseProfessional Services Transit1,961.55
4920Brand WiseProfessional Services Transit2,333.23
5JE AccrualNew Creative TransitProfessional Services Transit39.58
621924K&R ServicesProfessional Services Transit605.00
721923K&R ServicesProfessional Services Transit1,770.00
87100Data FactsProfessional Services Transit19.50
921949Language Line Services, IncProfessional Services Transit30.00
10JE AccrualAudit AccrualProfessional Services Transit975.00
1121875All Pest Solutions, Inc.Transit Building Maintenance85.00
1221952United Elevator ServicesTransit Building Maintenance13,100.50
13929BankCard CenterTransit Building Maintenance358.51
1421924K&R ServicesTransit Building Maintenance255.00
1521923K&R ServicesTransit Building Maintenance1,300.00
1621868Carpenter Bus SalesTransit Maintenance1,015.21
1721893O'Reilly Auto PartsTransit Maintenance186.88
1821893O'Reilly Auto PartsTransit Maintenance39.44
1921970Carpenter Bus SalesTransit Maintenance1,108.90
2021892Carpenter Bus SalesTransit Maintenance908.51
2121892Carpenter Bus SalesTransit Maintenance481.61
2221963Carpenter Bus SalesTransit Maintenance635.49
2321967Moody's Tire & Auto ServiceTransit Maintenance35.00
2421972Carpenter Bus SalesTransit Maintenance84.94
2521897Carpenter Bus SalesTransit Maintenance2,183.83
2621906Moody's Tire & Auto ServiceTransit Maintenance35.00
2721921K&R ServicesTransit Maintenance2,200.00
2821922K&R ServicesTransit Maintenance1,895.00
2921924K&R ServicesTransit Maintenance1,135.00
GL Transit Report
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Give something like this a try:

VBA Code:
Private Sub SortMerge()
Dim lrow As Long

'sort by columns A and B
    ActiveWorkbook.Worksheets("Sheet2").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Sheet2").Sort.SortFields.Add2 Key:=Range("A2:A300") _
        , SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    ActiveWorkbook.Worksheets("Sheet2").Sort.SortFields.Add2 Key:=Range("B2:B300") _
        , SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("Sheet2").Sort
        .SetRange Range("A1:D300")
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
    
'If columns A and B are the same, then sum the totals and delete the second line.
lrow = Worksheets("Sheet2").Cells.Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row

For x = lrow To 2 Step -1
    If Range("A" & x).Value = Range("A" & x - 1).Value And Range("B" & x).Value = Range("B" & x - 1).Value Then
        Range("D" & x - 1).Value = Range("D" & x - 1).Value + Range("D" & x).Value
        Range("D" & x).EntireRow.Delete
    End If
Next x
End Sub
 
Upvote 0
Solution
Note: When marking a post as the solution, please mark the actual post containing the solution (not your own post acknowledging some other post was the solution).
I have updated this thread for you.
 
Upvote 0

Forum statistics

Threads
1,215,326
Messages
6,124,265
Members
449,149
Latest member
mwdbActuary

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top