ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Subscript out of range error (https://www.excelbanter.com/excel-programming/299509-subscript-out-range-error.html)

enz[_2_]

Subscript out of range error
 
The following line of code results "subscript out of range error" on some
machines (other pc-s work just fine with the same code). All computers have
Windows XP and Excel XP.

---
G = Workbooks("hex_ee_converter.xls").Worksheets("Main ").Range("A35").Value
---

The workbook hex_ee_converter.xls exists and is open when this error message
occurs. The worksheet Main also exists and is open. The cell A35 also exists
and contains value 2.

What should I do to get rid of this error message?

enz



Hayeso[_2_]

Subscript out of range error
 
If you replace Range("A35") with Cells("A35) (or Cells
(1,35) then that should work.


-----Original Message-----
The following line of code results "subscript out of

range error" on some
machines (other pc-s work just fine with the same code).

All computers have
Windows XP and Excel XP.

---
G = Workbooks("hex_ee_converter.xls").Worksheets

("Main").Range("A35").Value
---

The workbook hex_ee_converter.xls exists and is open when

this error message
occurs. The worksheet Main also exists and is open. The

cell A35 also exists
and contains value 2.

What should I do to get rid of this error message?

enz


.


Bob Flanagan

Subscript out of range error
 
It sounds like the workbook or worksheet may not truly be open. Try the
following statements just before the error line:

msgbox Workbooks("hex_ee_converter.xls").Name
msgbox Workbooks("hex_ee_converter.xls").Worksheets("Main ").Name

If one of the above generates an error, it narrows the problem to either the
workbook or the worksheet

Bob Flanagan
Macro Systems
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel



"enz" wrote in message
...
The following line of code results "subscript out of range error" on some
machines (other pc-s work just fine with the same code). All computers

have
Windows XP and Excel XP.

---
G =

Workbooks("hex_ee_converter.xls").Worksheets("Main ").Range("A35").Value
---

The workbook hex_ee_converter.xls exists and is open when this error

message
occurs. The worksheet Main also exists and is open. The cell A35 also

exists
and contains value 2.

What should I do to get rid of this error message?

enz





enz[_2_]

Subscript out of range error
 
Problem solved. The ".xls" extension was missing from the filename.

enz




All times are GMT +1. The time now is 03:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com