LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default VBA Go to Today's Date

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
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
conditional formatting for cell date to equal today's date Sistereinstein Excel Worksheet Functions 2 September 10th 12 07:53 PM
date in Cell to change colors if the date is beyond today's date Pete Elbert Excel Discussion (Misc queries) 2 June 6th 09 06:31 AM
I need today's date returned as date format in formula CMIConnie Excel Discussion (Misc queries) 2 February 23rd 06 04:38 PM
Count number of cells with date <today's date Cachod1 New Users to Excel 2 January 28th 06 02:37 AM
count the number of cells with a date <= today's date Cachod1 New Users to Excel 3 January 27th 06 09:14 PM


All times are GMT +1. The time now is 07:34 PM.

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"