open work book to current 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
 
B

Bob Flanagan

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
 
R

ross

Easy!

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

these can be called from vba in the usally way

Enjoy
Ross
 
S

Smeesh

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?
 
S

Suzette

Try date()
Now() gives you information about the date and time
Date() gives you just date information.
 
B

Bill Kuunders

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
 
Top