LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default counting rows

I have a macro that will take a sorted spreadsheet, put separating blank rows
between each unique group, and add up a column which have numerical values
for each group. What I need to add to this macro is a count of the number of
rows are in each group. I want to put the count of rows for each group in
column D in the same row as the sum of the numbers.

Sub dept()


'\/data manipulation for in prog dept begins here\/


'selects all the data rows and sorts them by dept and then job number
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Sort Key1:=Range("D2"), Order1:=xlAscending, Key2:=Range("A2") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
DataOption2 _
:=xlSortNormal
Range("A1").Select


With ActiveSheet
.AutoFilterMode = False
End With

Range("A1").Select

'separates by dept and adds subtotal estimate hours for each dept
Set start = Range("D2")
i = 3
Do
Set rng = Cells(i, "D")
Set rngo = Cells(i - 1, "D")
Set rnge = Range(Cells(i, "D"), Cells(Rows.Count, "D").End(xlUp))
If rng.Value < rngo.Value Then
rng.Resize(2).EntireRow.Insert
rngo.Offset(1, 7).Formula = "=Sum(" & _
Range(start, rngo).Offset(0, 7).Address & ")"
i = i + 2
Set start = Cells(i, "D")
End If
i = i + 1
If Cells(i - 1, "D") = "" Then Exit Do
Loop

Range("A1").Select

End Sub
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
counting rows Darryl Excel Discussion (Misc queries) 2 January 29th 10 10:27 AM
Counting 'up' rows instead of down lawandgrace Excel Discussion (Misc queries) 1 December 1st 09 05:28 PM
Counting characters in multiple rows when rows meet specific criteria news.virginmedia.com Excel Worksheet Functions 3 June 28th 08 09:03 PM
Counting rows, then counting values. Michael via OfficeKB.com Excel Discussion (Misc queries) 7 August 4th 05 10:57 PM
Counting Rows Then Counting Values in Columns Michael via OfficeKB.com Excel Programming 1 June 1st 05 04:10 PM


All times are GMT +1. The time now is 10:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"