Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default subscript out of range

Hello,

I have a script I have been running which has suddenly run into a
"Runtime error '9' - subscript out of range" error.

The original code had this:
Selection.Copy
ActiveWindow.ActivateNext
Sheets("Spending").Select

And I changed it a while ago to this:
Selection.Copy
Windows("finances_2009.xlsx").Activate
Sheets("Spending").Select

And eventually to this:
Selection.Copy
Windows("finances_" + Right(Str(Year(Date)), 4) + ".xlsx").Activate
Sheets("Spending").Select

Only the top version now works. And the later 2 do not giving me the
subscript error. Any ideas how I can fix this?

Thanks,
Ben
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default subscript out of range

If the code is breaking on the Windows line, then maybe you don't have a window
named: finances_2009.xlsx

If you have multiple windows open, maybe the window captions look like:
finances_2009.xlsx:1
and
finances_2009.xlsx:2
and ...

If the line that's breaking is the Sheets("Spending").select line, then maybe
the window that you're trying to activate has a visible worksheet named
"Spending".



Ben wrote:

Hello,

I have a script I have been running which has suddenly run into a
"Runtime error '9' - subscript out of range" error.

The original code had this:
Selection.Copy
ActiveWindow.ActivateNext
Sheets("Spending").Select

And I changed it a while ago to this:
Selection.Copy
Windows("finances_2009.xlsx").Activate
Sheets("Spending").Select

And eventually to this:
Selection.Copy
Windows("finances_" + Right(Str(Year(Date)), 4) + ".xlsx").Activate
Sheets("Spending").Select

Only the top version now works. And the later 2 do not giving me the
subscript error. Any ideas how I can fix this?

Thanks,
Ben


--

Dave Peterson
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
Subscript out of Range Steve Excel Discussion (Misc queries) 3 April 15th 09 04:01 PM
Subscript out of range? Dave Birley Excel Programming 5 May 31st 07 03:14 PM
Subscript Out of Range Al Excel Programming 5 September 22nd 04 07:07 PM
Subscript out of range Bill Murphy Excel Programming 1 August 5th 04 08:52 AM
subscript out of range Todd Huttenstine[_3_] Excel Programming 1 June 11th 04 04:08 AM


All times are GMT +1. The time now is 10:26 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"