dcrt
dcrt

Reputation: 89

Reference workbook by path and name error: Subscript out of range

I get the "Subscript out of range" error from the line below:

Set WBset =  Workbooks("FilePath\PK18 - Unformatted.xls").Worksheets("PK18 - Unformatted")

I checked the sheet name and the filename and they are correct. The sheet exists.

Upvotes: 0

Views: 123

Answers (2)

vouchard orense
vouchard orense

Reputation: 1

wrong workbook name, should be the name not the path

Upvotes: 0

ACCtionMan
ACCtionMan

Reputation: 511

Presuming WBset is a Workbook Object, you need to remove the file path from the command so it looks like the following. The file needs to be open as Workbooks is a collection of the Workbook objects open.

Set WBset =  Workbooks("PK18 - Unformatted.xls").Worksheets("PK18 - Unformatted")

Upvotes: 1

Related Questions