View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Sorting data using 2 seperate columns

Hi,

Not proper subtotals but this gives the data layout and sum you want

Sub standard()
Dim MyRange
lastrow = Cells(Rows.Count, "C").End(xlUp).Row
For x = lastrow To 2 Step -1
If Cells(x, 2).Value < Cells(x - 1, 2).Value Then
Rows(x).EntireRow.Insert
End If
Next
lastrow = Cells(Rows.Count, "D").End(xlUp).Row
Set MyRange = Range("D1:D" & lastrow)
For Each c In MyRange
total = total + c.Value
If c.Offset(1, 0).Value = "" Then
c.Offset(1, 1).Value = total
total = 0
End If
Next
End Sub

Mike

"Dave Peterson" wrote:

This looks like you could use Data|subtotals (twice).

Or if you really only want the summary, you may want to learn about pivottables.

If you've never used pivottables, here are a few links:

Debra Dalgleish's pictures at Jon Peltier's site:
http://peltiertech.com/Excel/Pivots/pivottables.htm
And Debra's own site:
http://www.contextures.com/xlPivot01.html

John Walkenbach also has some at:
http://j-walk.com/ss/excel/files/general.htm
(look for Tony Gwynn's Hit Database)

Chip Pearson keeps Harald Staff's notes at:
http://www.cpearson.com/excel/pivots.htm

MS has some at (xl2000 and xl2002):
http://office.microsoft.com/downloads/2000/XCrtPiv.aspx
http://office.microsoft.com/assistan...lconPT101.aspx

ATanker62 wrote:

Hello all,

Here is my problem, large data set I have already organized it by state,
city, outergroup number.

AC AH AI BJ
188007 Williams IA 50
188007 Williams IA 126.851
180007 Belgrade MT 110
188111 Russelvile AR 70.014
188111 Texakana AR 169.001
188111 Barstow CA 60.006
188111 Barstow CA 50.108

What I want to do is the following

Insert a blank line between different cities, then a subtotal by the city,
then a total by the group number.

Data to look like this after work is done

AC AH AI BJ
188007 Williams IA 50
188007 Williams IA 126.851
176.851

180007 Belgrade MT 110
110.00

276.851

188111 Russelvile AR 70.014
70.014
188111 Texakana AR 169.001
169.001
188111 Barstow CA 60.006
188111 Barstow CA 50.108
110.108

349.123

Thanks


--

Dave Peterson