open work book to current date

  • Thread starter Thread starter Smeesh
  • Start date Start date
S

Smeesh

I have Excel 200 in the office and have created a projector booking form. I
want to improve the worksheet by getting it to open at the current date.

The worksheet (column a) has listed in it the date. Can anyone help with
some vb (or other method - I am not fussy) to open the sheet at the current
system date.

Thanks in advance
m
 
M, you can do it this way:

Dim T As Long
T = Now()
r = Application.Match(T, Columns(1), True)
Application.Goto Cells(r, 1)


assuming that you are on the sheet containing the dates and they are in
column A.

Bob Flanagan
Macro Systems
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel
 
Easy!

the formuals are
=Today()
of for a little more info
=now(),

these can be called from vba in the usally way

Enjoy
Ross
 
Hi Ross (and anybody else who wants to help!),

Thanks for the reply, however I had tried the Today() subfunction and could
not get it to work.

The VBA I have is:
Private Sub Workbook_Open()
Sheets("bookingsheet").Activate
Range((B4:B1454)=Today()).Select
End Sub

I get a compile error because of the :. Am I on the wrong track?
 
Try date()
Now() gives you information about the date and time
Date() gives you just date information.
 
Bob Flanigans answer was very close.
had to add the Dim r as long line and used the "date" rather then "today"
Tried it out putting the macro in the "this workbook" section.
It works! Thanks for the question I'll be using this myself.
Regards
Bill K

Private Sub Workbook_Open()
Dim r As Long
Dim T As Long
T = Date
r = Application.Match(T, Columns(1), True)
Application.Goto Cells(r, 1)
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