opening a worksheet at a specific point

G

Guest

i have a diary , i would like it to open at the specific date every time i
openen the file.PLEASE HELP>
 
R

Ron de Bruin

Hi Hi crusty53

You can try this find todays date in column A in "Sheet1"

Sub Find_Todays_Date()
Dim FindString As Date
Dim rng As Range
FindString = Date
With Sheets("Sheet1").Range("A:A")
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 "Nothing found"
End If
End With
End Sub

You van run the macro in the workbook open event in the thisworkbook module
 
G

Guest

Ron, thanks,but this is a bit too advanced for me.But if you have time i
would like to explore it further.Please a bit more of an explanation as to
what your reply means and how i go about performing what you told me.Your
humble beginner crusty.
 
R

Ron de Bruin

Hi

Copy the macro in a normal module

1. Alt-F11
2. Insert>Module from the Menubar
3. Paste the Code there
4. Alt-Q to go back to Excel
5. Alt-F8 to run the subs


Note :My Sheet is names "Sheet1"
Test the macro first and I help you to run it automatic
 
G

Guest

Hi Ron, Did as directed ,i get a run time error at 9,i think my sheet is
named"Diary" and the colunm is "B:B"
 
R

Ron de Bruin

Hi crusty53
i think my sheet is named"Diary" and the colunm is "B:B"
Think ? <g>

Change the Sheet name and column then like this


Sub Find_Todays_Date()
Dim FindString As Date
Dim rng As Range
FindString = Date
With Sheets("Diary").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 "Nothing found"
End If
End With
End Sub
 
G

Guest

Sub Find_Todays_Date()
Dim FindString As Date
Dim rng As Range
FindString = Date
With Sheets("Diary").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 "Nothing found"
End If
End With
End Sub


Hi Ron
still a run time error in 9 .At line with sheet name and colunms.
 
R

Ron de Bruin

Keep the macro in the normal module

We now use a event that run when you open the workbook
When you open the workbook in run your macro in the normal module

Private Sub Workbook_Open()
Call Find_Todays_Date
End Sub

You must copy this event in the Thisworkbook module

Right click on the Excel icon next to File in the Worksheet menu bar
Choose view code
Paste the event there
Alt-q to go back to Excel

See also
http://www.cpearson.com/excel/codemods.htm
 
G

Guest

Ron does the macro box always come up when you open the file and ask you to
enable macros.Thanks for all the help it was fantastic and you showed great
patience with a newby.
One more question please Ron is there a way to move cell comments or notes
 
R

Ron de Bruin

Hi crusty53

If you only open files you trust that you can set your security to Low
Tools>Macro....Security

Another way is to sign your macro's
Read this reply from Gord Dibben

Check out Help on Digital Signing and use the Self-Cert utility which allows you
to sign your projects on your own computer only.

Self-cert digital signatures are not exportable as are paid-for ones from Thawte
and Versisign.

Go to Start>Programs>Microsoft Office>Office Tools and build a selfcert from
there.

One more question please Ron is there a way to move cell comments

See the code on Debra's site
http://www.contextures.com/xlcomments03.html#CopyAdjacent
 

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

Top