LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default counter script

On Mar 22, 8:08 pm, Robert wrote:
Hello,

I need a counter script that can turn this input. I need the number of
inspections to be the number of unique dates. Thanks.

Name Inspection Date
ABC Trucking 1/1/2006
ABC Trucking 1/1/2006
ABC Trucking 1/23/2006
ABC Trucking 1/23/2006

into this output

Name Most recent inspection # of inspections
ABC Trucking 1/23/2006 2


Why not sort the data according to date in ascending order? You can
then delete all rows below the most recent date.

For example, after sorting the data you could write something like
this: (This hasn't been tested).

sub xxx()
Dim a
Dim counter
Dim currentDate
Dim nextDate
Dim strAdd
Dim endAdd

counter = Range("a1").currentregion.rows.count

for a = 1 to counter
currentDate = Range("c" & a).value
nextDate = range("c"&a).offset(1,0).value

if currentDate < nextDate Then
exit for
end if
next

activecell.offset(1,0).select
strAdd = selection.address
selection.end(xldown).select
endAdd = selection.address

range(stradd & ":" & endadd).entirerow.delete

counter = Range("a1").currentregion.rows.count
range("e1").value = "count is " & counter

end sub

matt

 
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
How do i set up a counter? Bulldog21 Excel Discussion (Misc queries) 2 July 23rd 08 02:12 PM
Counter EMoe[_115_] Excel Programming 2 July 31st 06 02:15 AM
Excel 2000/XP script to Excel97 script hat Excel Programming 3 March 2nd 04 03:56 PM
Counter donny Excel Programming 1 February 24th 04 05:35 PM
Counter Don Guillett[_4_] Excel Programming 0 July 17th 03 12:30 AM


All times are GMT +1. The time now is 05:25 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"