Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Look Up sheets

I am trying to work out a little code that will look up what month and year
it is, then once it has this activate the sheet that is using the month and
year as the sheet name.
if it is not in the sheets i want it to copy a sheet called "template" and
then rename the sheet using the month and year.

Thanks

Greg B


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Look Up sheets

Private Sub Workbook_Open()
Dim Lookup As String
Dim ws As Worksheet

Lookup = Format(Date, "mmmyyyy")
On Error Resume Next
Set ws = Worksheets(Lookup)
On Error GoTo 0
If Not ws Is Nothing Then

ws.Activate
Else

Worksheets.Add(after:=Worksheets(Worksheets.Count) ).Name = Lookup
End If
Set ws = Nothing
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Greg B" <browgregory(NO wrote in message
...
I am trying to work out a little code that will look up what month and year
it is, then once it has this activate the sheet that is using the month and
year as the sheet name.
if it is not in the sheets i want it to copy a sheet called "template" and
then rename the sheet using the month and year.

Thanks

Greg B



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
Print sheets by "All Sheets in workbook, EXCEPT for specific named sheets". Possible? Corey Excel Programming 2 December 11th 06 01:35 AM
Multiple Sheets (Need to create 500 individual sheets in one workbook, pulling DATA Amaxwell Excel Worksheet Functions 4 August 17th 06 06:23 AM
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? Dmitry Excel Worksheet Functions 6 March 29th 06 12:43 PM
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? Dmitry Excel Programming 6 March 29th 06 12:43 PM
Macro for filter on protected workbook that works for all sheets, no matter what sheets are named? StargateFanFromWork[_3_] Excel Programming 6 January 26th 06 06:31 PM


All times are GMT +1. The time now is 01:01 PM.

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"