Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JNW JNW is offline
external usenet poster
 
Posts: 480
Default Opening a file to a dynamic sheet

I am using a master file to access many other files that my department uses
often. These files have sheets named as the month and year (i.e. September
2005, October 2005, etc.). When opening these files, the current month's
sheet is not always (or ever) the active sheet which would be the desired
result.

How can I, upon opening these workbooks, active the sheet corresponding to
the current month?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Opening a file to a dynamic sheet

One way:

Option Explicit
Sub auto_open()
Dim myString As String

myString = Format(Date, "mmmm yyyy")
On Error Resume Next
Application.Goto Worksheets(myString).Range("A1")
If Err.Number < 0 Then
MsgBox "No worksheet named: " & myString
Err.Clear
End If
On Error GoTo 0

End Sub



JNW wrote:

I am using a master file to access many other files that my department uses
often. These files have sheets named as the month and year (i.e. September
2005, October 2005, etc.). When opening these files, the current month's
sheet is not always (or ever) the active sheet which would be the desired
result.

How can I, upon opening these workbooks, active the sheet corresponding to
the current month?

Thanks


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Opening a file to a dynamic sheet

Try this each time your master opens a workbook file:

Sub OpenCurrentMonth()
Dim CurMnth As String

CurMnth = Format(Date, "mmmm yyyy")
Worksheets(CurMnth).Activate

If ActiveSheet.Name < CurMnth Then
MsgBox ("There is no worksheet for this Month")
Exit Sub
End If
End Sub

Mike F
"JNW" wrote in message
...
I am using a master file to access many other files that my department uses
often. These files have sheets named as the month and year (i.e.
September
2005, October 2005, etc.). When opening these files, the current month's
sheet is not always (or ever) the active sheet which would be the desired
result.

How can I, upon opening these workbooks, active the sheet corresponding to
the current month?

Thanks



  #4   Report Post  
Posted to microsoft.public.excel.programming
JNW JNW is offline
external usenet poster
 
Posts: 480
Default Opening a file to a dynamic sheet



"Mike Fogleman" wrote:

Try this each time your master opens a workbook file:

Sub OpenCurrentMonth()
Dim CurMnth As String

CurMnth = Format(Date, "mmmm yyyy")
Worksheets(CurMnth).Activate

If ActiveSheet.Name < CurMnth Then
MsgBox ("There is no worksheet for this Month")
Exit Sub
End If
End Sub

Mike F
"JNW" wrote in message
...
I am using a master file to access many other files that my department uses
often. These files have sheets named as the month and year (i.e.
September
2005, October 2005, etc.). When opening these files, the current month's
sheet is not always (or ever) the active sheet which would be the desired
result.

How can I, upon opening these workbooks, active the sheet corresponding to
the current month?

Thanks




  #5   Report Post  
Posted to microsoft.public.excel.programming
JNW JNW is offline
external usenet poster
 
Posts: 480
Default Opening a file to a dynamic sheet

Oops...

Thanks guys. I ended up using a combination of both of your responses.
Works great.

JNW

"Mike Fogleman" wrote:

Try this each time your master opens a workbook file:

Sub OpenCurrentMonth()
Dim CurMnth As String

CurMnth = Format(Date, "mmmm yyyy")
Worksheets(CurMnth).Activate

If ActiveSheet.Name < CurMnth Then
MsgBox ("There is no worksheet for this Month")
Exit Sub
End If
End Sub

Mike F
"JNW" wrote in message
...
I am using a master file to access many other files that my department uses
often. These files have sheets named as the month and year (i.e.
September
2005, October 2005, etc.). When opening these files, the current month's
sheet is not always (or ever) the active sheet which would be the desired
result.

How can I, upon opening these workbooks, active the sheet corresponding to
the current month?

Thanks




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
Opening a specified sheet in an Excel file BarryHNZ Excel Discussion (Misc queries) 3 February 27th 09 08:36 PM
HOW TO LOCK/STOP THE OPENING OF 1 SHEET AMONG 3 IN 1 EXCEL FILE? Excel Locker[_2_] Excel Discussion (Misc queries) 1 September 20th 07 06:54 PM
Running Dialog Sheet when opening Excel File Yacov Excel Programming 1 June 16th 05 05:26 PM
VBA for opening file/populating combo box with sheet names Sinobato[_4_] Excel Programming 3 July 26th 04 06:35 PM
Copy a Sheet without physically opening the file Michael Kintner Excel Programming 1 January 5th 04 08:21 PM


All times are GMT +1. The time now is 09:58 AM.

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

About Us

"It's about Microsoft Excel"