Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Help amending code
Hi
I have the following code set to a commandbutton: Workbooks.Open Filename:= _ "\\Statistics\Year 05-06\September.xls" However, if the sheet is already open in the background, I get an error message. What can I add to this code so that, if the sheet is already open, it just switches over to it? TIA Steve |
#2
|
|||
|
|||
On Error Resume Next Set oWb = Workbooks("September.xls") If oWb Is Nothing Then Set oWb = Workbooks.Open Filename:= _ "\\Statistics\Year 05-06\September.xls" Endf If On Error Goto 0 oWb.Activate -- HTH RP (remove nothere from the email address if mailing direct) "Steve" wrote in message oups.com... Hi I have the following code set to a commandbutton: Workbooks.Open Filename:= _ "\\Statistics\Year 05-06\September.xls" However, if the sheet is already open in the background, I get an error message. What can I add to this code so that, if the sheet is already open, it just switches over to it? TIA Steve |
#3
|
|||
|
|||
Thanks Bob.
For some reason I keep getting the red error line; the "Filename" part seems to be the problem...? Steve |
#4
|
|||
|
|||
Sorry Steve, missed the brackets
On Error Resume Next Set oWb = Workbooks("September.xls") If oWb Is Nothing Then Set oWb = Workbooks.Open(Filename:= _ "\\Statistics\Year 05-06\September.xls") End If On Error GoTo 0 oWb.Activate -- HTH RP (remove nothere from the email address if mailing direct) "Steve" wrote in message oups.com... Thanks Bob. For some reason I keep getting the red error line; the "Filename" part seems to be the problem...? Steve |
#5
|
|||
|
|||
That did it. Thanks a lot, Bob.
Best, Steve |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Change case...help please | Excel Worksheet Functions | |||
Macro for changing text to Proper Case | Excel Worksheet Functions | |||
Using other workbooks.. | Excel Worksheet Functions | |||
Make Change Case in Excel a format rather than formula | Excel Worksheet Functions | |||
Help with Amending this Code Please | Excel Worksheet Functions |