View Single Post
Old 12-29-2005, 11:17 AM
rnstewart rnstewart is offline
Join Date: Nov 2005
Posts: 6
Default Mysterious "Subscript out of range" error

I have a VBA application I've developed, and one line of code works fine on my computer but refuses to work on another.

The code in question is designed to read the value of a particular cell of the spreadsheet that contains the app. It looks like this:

If (Workbooks("FileConvert.xls").Worksheets("Sheet1").Range("B1").Value <> "") Then
I.e., "Look at this workbook (named 'FileConvert.xls'), get the value from Cell B1 in sheet 'Sheet1' and see if it is empty".

On my machine, this works fine. On the other one, it throws a "Subscript out of range" error. Both computers are running Excel 2002. I also tried referencing the sheet by index instead of name (i.e., "Worksheets(1)" instead of "Worksheets("Sheet1")").

Any ideas what could be going wrong here? It seems like a simple enough command.
Reply With Quote