find current date

mgbcab

New Member
Joined
Nov 6, 2009
Messages
7
I have a workbook where each tab represents a week. The tab is named by the date of that Monday, so this week would be "Mar 7". In each tab, cell B1 has this same date, also the dates of the current week are listed in B3 to F3.
What I would like to do is when the user opens up the file, it automatically goes to today's date's column or even the current week tab is fine.
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
I would think of looking for the dates on the sheets, presuming they are valid dates. Maybe:

In ThisWorkbook Module:
Rich (BB code):
Option Explicit
    
Private Sub Workbook_Open()
Dim lDate As Long
Dim wks As Worksheet
Dim i As Long
    
    lDate = CLng(Date)
    For Each wks In ThisWorkbook.Worksheets
        For i = 2 To 6
            If wks.Cells(3, i).Value2 = CLng(Date) Then
                Application.Goto wks.Cells(3, i)
                GoTo Jumpout
            End If
        Next
    Next
Jumpout:
    
'Remaining code...
End Sub
Hope that helps,

Mark
 
Upvote 0
I get an error message "Ambigous name detected:Workbook open". I do have another workbook open macro before it. I assume this goes in ThisWorkbook?
 
Upvote 0
I get an error message "Ambigous name detected:Workbook open". I do have another workbook open macro before it. I assume this goes in ThisWorkbook?

Yes, it does go in ThisWorkbook module.

You cannot have two same-named procedures (a Sub or Function) in the same module. You will want to incorporate just the code and variable deeclarations and meld it with what you already have.

Hope that helps,

Mark
 
Upvote 0
Yes, it does go in ThisWorkbook module.

You cannot have two same-named procedures (a Sub or Function) in the same module. You will want to incorporate just the code and variable deeclarations and meld it with what you already have.

Hope that helps,

Mark

Got it, I included your code with my existing and it worked. Thanks
 
Upvote 0

Forum statistics

Threads
1,224,507
Messages
6,179,183
Members
452,893
Latest member
denay

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top