Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dpj dpj is offline
external usenet poster
 
Posts: 1
Default How? to go to cell when opening file

I have a column containing dates of the year. How can the file be opened
to go to the cell containing todays date?



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default How? to go to cell when opening file

Here's some code that goes into the ThisWorkbook code module

Private Sub Workbook_Open()
Dim oFoundCell As Range

With ActiveSheet.Range("A1:A100")
Set oFoundCell = .Find(what:=Date, _
LookIn:=xlFormulas)
If Not oFoundCell Is Nothing Then
oFoundCell.Activate
End If
End With

End Sub


Change the range to suit.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"dpj" wrote in message
...
I have a column containing dates of the year. How can the file be opened
to go to the cell containing todays date?



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How? to go to cell when opening file

Thank you for that Bob.
I had a bit of trouble to start with but after changing line:-
Set oFoundCell = .Find(what:=Date, LookIn:=xlFormulas)
to
Set oFoundCell = .Find(Date, LookIn:=xlFormulas) I found it worked.

Can the code be modified to select the correct sheet if there are more
than one, eg. 2003,2004,2005 etc.?



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default How? to go to cell when opening file

This should do it

Private Sub Workbook_Open()
Dim oFoundCell As Range
Dim sYear As String

sYear = CStr(Year(Date))
Worksheets(sYear).Activate
With ActiveSheet.Range("A1:A100")
Set oFoundCell = .Find(what:=Date, _
LookIn:=xlFormulas)
If Not oFoundCell Is Nothing Then
oFoundCell.Activate
End If
End With

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"dpj" wrote in message
...
Thank you for that Bob.
I had a bit of trouble to start with but after changing line:-
Set oFoundCell = .Find(what:=Date, LookIn:=xlFormulas)
to
Set oFoundCell = .Find(Date, LookIn:=xlFormulas) I found it worked.

Can the code be modified to select the correct sheet if there are more
than one, eg. 2003,2004,2005 etc.?



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



Reply
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
how do i set up opening a file from a cell in excel spreadsheet Scott Excel Discussion (Misc queries) 1 September 21st 09 06:01 PM
how do i set up opening a file from a cell in excel spreadsheet Scott Excel Discussion (Misc queries) 2 September 21st 09 02:39 PM
File:1 and File:2 -- Double Files when Opening One File dallin Excel Discussion (Misc queries) 1 January 25th 07 02:53 AM
opening an excel file opens a duplicate file of the same file skm Excel Discussion (Misc queries) 1 December 7th 05 05:52 PM
"Too many different cell formats" is preventing file from opening Jed Excel Discussion (Misc queries) 1 September 30th 05 09:40 PM


All times are GMT +1. The time now is 11:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"