LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 533
Default Reactivating file based on text value producees subscript error

Whenever I get a subscript out of range error it is inevidentably because
the the workbook or worksheet or whatever I'm supplying the text name for
does not exist in the given context. You could have helped us by telling
which line in your code produces the error but I think we can safely say
that either:

-there is no workbook named "fxrm_update.xls" open.
-if there is, it does not have a worksheet named "lookup".
-if it does, there is no workbook open with the name in cell d39 of that
sheet.

Excel is not case sensitive in these things but it is otherwise quite
literal, so you can't omit the ".xls" from a workbook name for example.

--
Jim
"Andyjim" wrote in message
...
Hi-
I've gotten tremendous help from you before. I hope you can help me here.

I use the following code to reactivate an open file to which we don't know
the name, but the name exists in the form of text in a cell in the
currently
active file called fxRM_Update.xls.
This code produces a subscript out of range error.

Sub Update2()
'Defines user file in fxRM_Update.xls
'Update macro calls this macro each time it must return to user file

Dim bk As Workbook, bk1 As Workbook
Dim sstr As String
Set bk = Workbooks("fxRM_Update.xls")
sstr = bk.Worksheets("lookup").Range("d39").Value
Set bk1 = Workbooks(sstr)
bk1.Activate

End Sub

I would be very grateful if you could help me.

Andy




 
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
cancelling copy command after reactivating workbook PattiP Excel Worksheet Functions 0 January 17th 08 04:17 AM
Runtime Error - Subscript out of range despite On Error statement DoctorG Excel Programming 3 July 28th 06 03:56 PM
subscript out of range error for .csv file and vlookup cultgag[_5_] Excel Programming 1 February 15th 06 07:03 PM
Run Time Error 9 (Subscript out of Range) for XLA file ExcelMonkey Excel Discussion (Misc queries) 3 October 5th 05 03:34 PM
Type Mismatch error & subscript out of range error Jeff Wright[_2_] Excel Programming 3 May 14th 05 07:14 PM


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