Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Perfect! Thanks Jim, much appreciated.
Regards, Ricky On Aug 17, 7:40*pm, "Jim Cone" wrote: Modified the code to repeat up to 15 times. After each try, if the date is not found, the date is reduced by one day and the code repeats. '--- Sub Find_Todays_Date_R1() Dim FindString As Date Dim Rng As Range Dim N As Long FindString = CLng(Date) For N = 1 To 15 With Sheets("Daily").Range("B:B") * Set Rng = .Find(What:=FindString, _ * After:=.Cells(.Cells.Count), _ * LookIn:=xlFormulas, _ * LookAt:=xlWhole, _ * SearchOrder:=xlByRows, _ * SearchDirection:=xlNext, _ * MatchCase:=False) End With If Not Rng Is Nothing Then * Application.Goto Rng, True * Exit Sub Else * FindString = FindString - 1 End If Next MsgBox "That date is not entered" Range("A4").Select End Sub '--- Jim Cone Portland, Oregon USA *.http://www.mediafire.com/PrimitiveSoftware*. (Data Rows add-in: Custom Shading, Deleting, Inserting) "Ricky" wrote in ... Thanks Garry. I'm not really keen to use the Group option as I use Excel 2003 at home (but use Excel 2007 at work). *Yes, I suppose I can always save the worksheet at today's date, though a macro is preferable to move around my data quickly. I've found this bit of code, though it fails if I have not got any entry dated today's date in my list - though I might have a date close to it, and ceratinly with 13 days of it. Can this be modified at all to go the the closest date before today's date? Regards Ricky (via spencer's account) Sub Find_Todays_Date() '--If you have date's in column B then this example will select the cell with today's date. Dim FindString As Date Dim Rng As Range FindString = CLng(Date) With Sheets("Daily").Range("B:B") Set Rng = .Find(What:=FindString, _ After:=.Cells(.Cells.Count), _ LookIn:=xlFormulas, _ LookAt:=xlWhole, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False) If Not Rng Is Nothing Then Application.Goto Rng, True Else MsgBox "That date is not entered" End If End With Range("A4").Select End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
conditional formatting for cell date to equal today's date | Excel Worksheet Functions | |||
date in Cell to change colors if the date is beyond today's date | Excel Discussion (Misc queries) | |||
I need today's date returned as date format in formula | Excel Discussion (Misc queries) | |||
Count number of cells with date <today's date | New Users to Excel | |||
count the number of cells with a date <= today's date | New Users to Excel |