Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Date Turns Green 90-Days before the date shown in cell | Excel Worksheet Functions | |||
business day date from a specific date based on a number of days | Excel Worksheet Functions | |||
Report Date - Date Recv = Days Late, but how to rid completed date | Excel Worksheet Functions | |||
Excel Formula to calulate number of days passed from date to date | Excel Discussion (Misc queries) | |||
Calculating days between current date and a date in future NETWORKDAYS() function | Excel Worksheet Functions |