# Solved excel sort then sum

Asustek computer inc. / P5p800
October 8, 2011 at 07:01:30
Specs: Windows XP, P4 3GHz/ 2GB
 Excel: make macro or something ;) for this:input:A________B________C1________ 43________ 54________ 31________ 23________ 43________ 54________ 7whishA________B________C1________ 41________ 2 __________________ 63________ 53________ 43________ 5_________________144________ 34________ 7_________________10how to do this (automatic) with macro or ...

See More: excel sort then sum

#1
October 9, 2011 at 06:39:10
 First, a posting tip:The next time you need to post data in this forum, please click on the blue line at the end of any of my posts and read the instructions found via that link. Thanks!Try this code:```Sub SortThenSum() 'Determine last row with data in Column A lastRw = Range("A" & Rows.Count).End(xlUp).Row 'Sort data Range("A1:B" & lastRw).Sort Key1:=Range("A1"), Order1:=xlAscending 'Initialize Row counter variable nxtRw = 1 'Loop through Rows Do While Cells(nxtRw, 1) <> "" 'Compare current Row data to next Row data (Column A) If Cells(nxtRw + 1, 1) <> Cells(nxtRw, 1) Then 'If they don't match, insert Row at change Cells(nxtRw + 1, 1).EntireRow.Insert 'Use SUMIF to SUM matching data, place in Column C Cells(nxtRw + 1, 3) = _ WorksheetFunction.SumIf(Range("A1:A" & lastRw), "=" & _ Cells(nxtRw, 1), Range("B1:B" & lastRw)) 'Increment Row counter and last Row variable to account for inserted Row nxtRw = nxtRw + 1 lastRw = lastRw + 1 End If 'Increment Row counter and check again nxtRw = nxtRw + 1 Loop End Sub```Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Report •

#2
October 14, 2011 at 01:13:06
 Dear Sir! My Friend, Massa :) Thank You very much!This is it!So, what book, tutorial you recommand me where can I find sintax, commands, words for makeing such routines?Colour, bold fonts of subtotal (for example), strech cells, links routines etc. Thanks to You, again, and Computing.Net!Bye!

Report •

#3
October 14, 2011 at 05:06:27
 I know that there are books and websites available to learn VBA but I have no suggestions since I am self-taught.Good luck!Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Report •
Related Solutions