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

This assumes the referenced workbook is open.

Even though you have verified the spelling is correct, it is incorrect or
you wouldn't get the error (assuming that line causes the error).

Assuming the book is the activewindow when you run the code.

Dim wndw as Window
set wndw = Activewindow
Workbooks.Open Filename:= _
"C:\My Documents\cat.xls"

wndw.Activate

msgbox "-" & lcase(Application.Substitute(activeworkbook.Name," ","_")) _
& "<-" & vbnewline & _
lcase(Application.Substitute("-C C Schedule Regular.xls<-"," ","_"))

otherwise
Dim bk as Workbook
Workbooks.Open Filename:= _
"C:\My Documents\cat.xls"
for each bk in Workbooks
if instr(1,bk.Name,"Sched",vbTextCompare")0 then
bk.Activate
exit for
End if
Next

Or check the spelling again - might have two spaces where you only think
there is one.

--
Regards,
Tom Ogilvy





"Darrell Wesley" wrote in message
...
The following lines of code yield a "Subscript out of range" error 9.


Workbooks.Open Filename:= _
"C:\My Documents\cat.xls"
Windows("C C Schedule Regular.xls").Activate

Both xls documents are in the same folder and spelling including spaces

has
been verified as correct. Why does this yield a Subscipt out of range

error?



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 problem No Name Excel Programming 0 September 15th 04 05:56 PM
Subscript out of range problem JE McGimpsey Excel Programming 0 September 15th 04 05:55 PM
Subscript out of range? Jason Hancock Excel Programming 3 May 26th 04 07:11 PM
Excel Macro Problem, Add-in need to work in every workbook & Error:9 Subscript out of range Burak[_2_] Excel Programming 1 October 31st 03 08:09 PM
Subscript Out of Range John Wilson Excel Programming 2 September 7th 03 04:07 AM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"