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: 8
Default Mark if checkin date is within 30 days of checkout date where name isthe same.

All I have the following function which I got from here and it is
very
slow but I thought it was working until I noticed that sometimes the
first occurance of a name is still appearing as within 30 days. What
is causing this? Is it because name can appear more than twice?

I need to mark any row where the checkin date is within 30 days of
checkout date of previous record where name is the same.

Function within30(Name As Range, NameRng As Range, Admit As Range,
Discharge As Range) As String
Application.Volatile
Dim NameCount As Long
Dim ChkOut As Long
Dim ChkIn As Long
Dim f As Range
NameCount = Application.WorksheetFunction.CountIf(NameRng, Name)
If NameCount = 1 Then
within30 = ""
Exit Function
End If
For n = 1 To NameCount
For r = Name.Row + 1 To NameRng.Rows.Count - 1
Debug.Print r
If Cells(r, Name.Column) = Name Then
ChkOut = Cells(Name.Row, Discharge.Column)
ChkIn = Cells(r, Admit.Column)
If ChkIn - ChkOut <= 30 Then
within30 = "X"
Exit For
End If
Set Name = Cells(r, Name.Column)
End If
Next
Next
End Function
 
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
Date Turns Green 90-Days before the date shown in cell ajaminb Excel Worksheet Functions 7 September 28th 08 11:36 PM
business day date from a specific date based on a number of days Jana Excel Worksheet Functions 2 January 2nd 08 06:21 PM
Report Date - Date Recv = Days Late, but how to rid completed date MS Questionnairess Excel Worksheet Functions 1 January 24th 07 11:05 PM
Excel Formula to calulate number of days passed from date to date K. Mack Excel Discussion (Misc queries) 8 January 4th 07 11:27 PM
Calculating days between current date and a date in future NETWORKDAYS() function Faheem Khan Excel Worksheet Functions 2 February 10th 05 07:18 PM


All times are GMT +1. The time now is 02:18 AM.

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

About Us

"It's about Microsoft Excel"