ExcelBanter

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

Sri via OfficeKB.com

subscript out of range
 
Hello,

While I execute the following code, I get "subscript out of range" error at
the last line.
The file "Report_2009-04-16.xls" exists in the location mentioned in vPath.
Could any body help me out here please ...

Dim srcDBName As String
Dim xlw_source As Excel.Workbook

inpDate = "2009-04-16"
vPath = ThisWorkbook.Path
srcDBName = vPath & "\" & "Report_" & inpDate & ".xls"
Set xlw_source = Excel.Workbooks(srcDBName)

--
Message posted via http://www.officekb.com


Jacob Skaria

subscript out of range
 
Set xlw_source = Workbooks.Open(srcDBName)

--
If this post helps click Yes
---------------
Jacob Skaria


"Sri via OfficeKB.com" wrote:

Hello,

While I execute the following code, I get "subscript out of range" error at
the last line.
The file "Report_2009-04-16.xls" exists in the location mentioned in vPath.
Could any body help me out here please ...

Dim srcDBName As String
Dim xlw_source As Excel.Workbook

inpDate = "2009-04-16"
vPath = ThisWorkbook.Path
srcDBName = vPath & "\" & "Report_" & inpDate & ".xls"
Set xlw_source = Excel.Workbooks(srcDBName)

--
Message posted via http://www.officekb.com



Gary''s Student

subscript out of range
 
Need to make sure the instance exists and is properly referenced:

Sub dural()
Dim xlw_source As Workbook
Dim srcDBName As String
srcDBName = "C:\test\beta.xls"
shortName = "beta.xls"
Workbooks.Open Filename:=srcDBName
Set xlw_source = Excel.Workbooks(shortName)
End Sub

--
Gary''s Student - gsnu200846


"Sri via OfficeKB.com" wrote:

Hello,

While I execute the following code, I get "subscript out of range" error at
the last line.
The file "Report_2009-04-16.xls" exists in the location mentioned in vPath.
Could any body help me out here please ...

Dim srcDBName As String
Dim xlw_source As Excel.Workbook

inpDate = "2009-04-16"
vPath = ThisWorkbook.Path
srcDBName = vPath & "\" & "Report_" & inpDate & ".xls"
Set xlw_source = Excel.Workbooks(srcDBName)

--
Message posted via http://www.officekb.com



Sri via OfficeKB.com

subscript out of range
 
Hello Jacob,

Thansk for your reply. It works fine.

Sri



Jacob Skaria wrote:
Set xlw_source = Workbooks.Open(srcDBName)

Hello,

[quoted text clipped - 10 lines]
srcDBName = vPath & "\" & "Report_" & inpDate & ".xls"
Set xlw_source = Excel.Workbooks(srcDBName)


--
Message posted via http://www.officekb.com



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

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