Find and display today's date cel

  • Thread starter Thread starter awander
  • Start date Start date
A

awander

I have a spreadsheet that is used for scheduling. Column A ha
consecutive dates in it. I want to write a mcro that will search thi
column for the current date, and then display the worksheet with tha
cell in the top left corner. I am pretty new to VBA, and am gettin
nowhere with this. DOes anyone have a macro that does this, o
something similar, that I could use or refer to?

thanks,

And
 
Hi
try the following macro:
Sub goto_date()
Dim rng As Range
Dim ret_value

Set rng = ActiveSheet.Range("A1:A100")
ret_value = Application.Match(CDbl(Date), rng, 0)
If IsError(ret_value) Then
MsgBox "Current date not found"
Else
Application.Goto reference:=ActiveSheet.Cells(ret_value, 1),
scroll:=True
End If
End Sub
 
Try this

Sub Find_Todays_Date()
Dim FindString As Date
Dim Rng As Range
FindString = Date Set Rng = Range("A:A").Find(What:=FindString, _
After:=Range("A" & Rows.Count), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then Application.Goto Rng, True
End Sub
 
Oops Line wrap

This is the good one

Sub Find_Todays_Date()
Dim FindString As Date
Dim Rng As Range
FindString = Date
Set Rng = Range("A:A").Find(What:=FindString, _
After:=Range("A" & Rows.Count), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then Application.Goto Rng, True
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


Ron de Bruin said:
Try this

Sub Find_Todays_Date()
Dim FindString As Date
Dim Rng As Range
FindString = Date Set Rng = Range("A:A").Find(What:=FindString, _
After:=Range("A" & Rows.Count), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then Application.Goto Rng, True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top