If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > VBA Code

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-16-06, 07:59
Wildsmeister Wildsmeister is offline
Registered User
 
Join Date: Jul 2005
Location: Southampton, UK
Posts: 7
VBA Code

Hi,

I need what I am sure is a really easy bit of code on an excel workbook.

I need to ensure that whenever a spreadsheet I have created is opened, it always defaults to a certain worksheet, irrespective of which worksheet it was saved on.

Hope someone can help

Cheers
Paul
Reply With Quote
  #2 (permalink)  
Old 02-16-06, 08:47
MikeTheBike MikeTheBike is offline
Registered User
 
Join Date: Apr 2004
Location: Derbyshire, UK
Posts: 714
Hi

Try this code in the 'ThisWorkbook' module

Code:
Private Sub Workbook_Open()
    On Error Resume Next
    Worksheets("YourSheetName").Select
End Sub
The On Error code causes errors to be ignored if the sheet name does not exist.

HTH

MTB
Reply With Quote
  #3 (permalink)  
Old 02-16-06, 09:50
Wildsmeister Wildsmeister is offline
Registered User
 
Join Date: Jul 2005
Location: Southampton, UK
Posts: 7
Thats perfect Mike Cheers

Paul
Reply With Quote
  #4 (permalink)  
Old 02-16-06, 18:14
Fazza Fazza is offline
Registered User
 
Join Date: Feb 2006
Posts: 113
Some other thoughts.

You could have some similar code to that offered by Mike but running on file closure. If it is critical, you might also consider if the file is opened without macros enabled. And, in case the worksheet name changes, use the CodeName property.

regards,
Fazza
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On