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/349511-subscript-out-range-error.html)

Vishal[_3_]

Subscript out of range error
 
Hi

I am trying to open a file and do some operation on it.

I am using the following statement in my code -

strMetricsFile = ActiveWorkbook.FullName
While Trim(Workbooks(strMetricsFile).ActiveSheet.Range(" A" &
intCurrentRowMetrics).Value) < ""

I am getting an error message - Subscript out of range

If I use the File name directly in the above statement instead of
strMetricsFile, the code runs fine. But if I use the variable instead
of the file name, it gives me the error.

Can anyone please help !

Thanks
Vishal


Bob Phillips[_6_]

Subscript out of range error
 
I would guess it should be

strMetricsFile = ActiveWorkbook.Name
While Trim(Workbooks(strMetricsFile).ActiveSheet.Range(" A" &
intCurrentRowMetrics).Value) < ""


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Vishal" wrote in message
oups.com...
Hi

I am trying to open a file and do some operation on it.

I am using the following statement in my code -

strMetricsFile = ActiveWorkbook.FullName
While Trim(Workbooks(strMetricsFile).ActiveSheet.Range(" A" &
intCurrentRowMetrics).Value) < ""

I am getting an error message - Subscript out of range

If I use the File name directly in the above statement instead of
strMetricsFile, the code runs fine. But if I use the variable instead
of the file name, it gives me the error.

Can anyone please help !

Thanks
Vishal




Vishal[_3_]

Subscript out of range error
 
thanks !
it worked.

Now I am facing a different problem. The macro runs fine on my
machine. But when I execute it on some other machine, I get an error
message- "Can't fine project or library" ! Any suggestions ?


Bob Phillips[_6_]

Subscript out of range error
 
Sounds like you have a referenced library that is not on that machine. Go to
ToolsReferences in the VBIDE and see what is missing.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Vishal" wrote in message
oups.com...
thanks !
it worked.

Now I am facing a different problem. The macro runs fine on my
machine. But when I execute it on some other machine, I get an error
message- "Can't fine project or library" ! Any suggestions ?





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

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