View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
kounoike[_2_] kounoike[_2_] is offline
external usenet poster
 
Posts: 126
Default Find end of week and insert Data

Assuming data are populated in ascending order starting at A2 and
there is no blank cells, no Saturday and no Sunday.
then try this one.

Sub weekdaycount()
Dim wrng As Range, lrng As Range
Dim count As Long

Set wrng = Cells(2, "a") '<<=== start range - change if need
Set lrng = Cells(Cells.Rows.count, "a").End(xlUp)
Do While (wrng.Row <= lrng.Row)
count = 1
Do While (Weekday(wrng) <= Weekday(wrng(2)))
If wrng(2) < "" Then
Set wrng = wrng(2)
count = count + 1
Else
Exit Do
End If
Loop
Set wrng = wrng(2)
wrng.EntireRow.Insert
wrng(0) = "Weekly Totals"
wrng(0, 2) = count
Loop
End Sub

keizi

"parteegolfer"
wrote in
message
news:parteegolfer.23z1ob_1141184102.6927@excelforu m-nospam.com...

I am trying to count dates in column A and at the end of every work

week
(monday thru Friday) automatically enter "Weekly Totals" in the row
below the last date of the week in column A

EXAMPLE:

Example:

Date
01/01/06
01/01/06
01/02/06
01/03/06
01/03/06
Weekly Totals
01/08/06
01/09/06
01/10/06
01/11/06
01/11/06
01/12/06
Weekly Totals

Can anyone Help?


--
parteegolfer
----------------------------------------------------------------------

--
parteegolfer's Profile:

http://www.excelforum.com/member.php...o&userid=31951
View this thread:

http://www.excelforum.com/showthread...hreadid=517623