Chart to be first sheet to open

  • Thread starter Thread starter gazza67
  • Start date Start date
G

gazza67

Hi,

I have a workbook with many sheets. I can make any worksheet I want to
be the initial sheet to be opened when the document is opened, HOWEVER
I want to make a chart the initial sheet to open and I cant make this
work.

I am running excel2000

Cheers,
Gazza
 
Paste this into the workbook code area:

Private Sub Workbook_Open()
Sheets("ChartName").Activate
End Sub

Make sure that:
1. You paste it into the workbook code window, not in a module.
2. Macros are set to run when workbook opens.
 
It does work with a chart sheet (I just tested it to be sure). Where did you
put the code?

- Jon
 
I put it in the workbook code window (in the title bar for the window
it says Microsoft Visual Basic - MyBookName.xls - [ThisWorkbook(code)]

If I modify the code and put a normal worksheet in it works as
expected, if I change the code to the name of a chartsheet I get

Run-time error '9':
Subscript out of range

Gary
 
Go back to Tevuna's original response. Did you paste the code exactly as is?
Did you then change to the correct chart sheet name, in quotes? If not, you
will get the RTE 9 Subscript error you report. Note that the default name
"Chart1" has no space before the number.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


gazza67 said:
I put it in the workbook code window (in the title bar for the window
it says Microsoft Visual Basic - MyBookName.xls - [ThisWorkbook(code)]

If I modify the code and put a normal worksheet in it works as
expected, if I change the code to the name of a chartsheet I get

Run-time error '9':
Subscript out of range

Gary



It does work with a chart sheet (I just tested it to be sure). Where did
you
put the code?

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. -http://PeltierTech.com
_______
 
Jon and Tevuna,

Thanks for you help. My problem was that I was using the statement
WorkSheets("ChartName").Activate .

This statement works fine for worksheets but throws the RTE 9 error
when applied to a chart.

I needed the statement
Sheets("ChartName").Activate .
Which Tevuna correctly supplied, once again,

THANKs


Go back to Tevuna's original response. Did you paste the code exactly as is?
Did you then change to the correct chart sheet name, in quotes? If not, you
will get the RTE 9 Subscript error you report. Note that the default name
"Chart1" has no space before the number.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. -http://PeltierTech.com
_______


I put it in the workbook code window (in the title bar for the window
it says Microsoft Visual Basic - MyBookName.xls - [ThisWorkbook(code)]
If I modify the code and put a normal worksheet in it works as
expected, if I change the code to the name of a chartsheet I get
Run-time error '9':
Subscript out of range
 
Back
Top