LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Sorting, FIltering & Counting

How about trying this:

Option Explicit
Sub Getcount()
Dim nodupes As Collection
Set nodupes = New Collection
Dim rng As Range
Dim cell As Range
Dim i As Long
With Worksheets("sheet1")
Set rng = .Range("d27", .Range("d27").End(xlDown))
End With
With Worksheets("sheet2")
.Range("C:D").ClearContents
On Error Resume Next
For Each cell In rng
nodupes.Add cell.Value, cell.Text
Next
For i = 1 To nodupes.Count
.Cells(i, "C").Value = nodupes.Item(i)
.Cells(i, "D").Formula _
= "=countif(" & rng.Address(external:=True) & ",C" & i & ")"
Next i
End With

End Sub




paragtim wrote:

I have been trying to work this out since the thread was raised. I'm
pretty sure the problem is between the keyboard and the seat.

The background:
Sheet1 has data in columns a - i. Columns A to c has time and date
info. Column d has the name of the agent raising the query.
Columns e - i has the outcomes from the task undertaken.
Sheet 1 has auto filters set on row 26 columns a - i
New data is added by inserting rows from row 29

What I want to do is generate a unique list of names on sheet 2 in
Column C with, along side each name, in Column D, the number of times
the agents name has appeared in Column D on sheet 1. For example Smith
6, Evans 3

Tom Olglvy!! sent me the code below but it generates an error

"Run Time Error 1004" Application defined or object-defined error

Can anyone help me put it right please

Many thanks

Sub Getcount()
Dim nodupes As Collection
Set nodupes = New Collection
Set rng = Range("sheet1!D27", Range("Sheet!d27").End(xlDown))
Range("sheet2!C:D").ClearContents
On Error Resume Next
For Each cell In rng
nodupes.Add cell.Value, cell.Text
Next
For i = 1 To nodupes.Count
Cells(i, "C").Value = nodupes.Item(i)
Cells(i, "D").Formula = "=countif(A:A,C" & i & ")"
Next i

End Sub

--
paragtim
------------------------------------------------------------------------
paragtim's Profile: http://www.excelforum.com/member.php...o&userid=34010
View this thread: http://www.excelforum.com/showthread...hreadid=537740


--

Dave Peterson
 
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
Sorting or Filtering JD Excel Discussion (Misc queries) 5 August 21st 09 05:58 PM
Sorting/Filtering Brandy Excel Discussion (Misc queries) 5 February 11th 08 09:02 PM
Filtering A and counting B SAM Excel Discussion (Misc queries) 2 April 19th 07 11:32 AM
counting filtering data x taol Excel Programming 1 February 3rd 06 07:07 AM
Sorting and filtering dsbiloxi Excel Worksheet Functions 7 March 10th 05 11:55 PM


All times are GMT +1. The time now is 04:56 PM.

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"