run time error 9 in a Set statement

micos excel

New Member
Joined
Dec 25, 2017
Messages
2
When this sub is run a get run time error (subscript out of range) at stared statement.
I know the location is correct because I used this location to open the workbook.

This error message does not seem to apply this statement.

Help


Sub SingleRecord()<o:p></o:p>

Rem Records payroll data inrecords file<o:p></o:p>
Static bFileopen As Boolean<o:p></o:p>
Dim wbRec As Workbook<o:p></o:p>
Dim wbPR As Workbook<o:p></o:p>
Workbooks.Open"I:\Rosy's\Pay Roll\2017 Pay Records .xlsm"<o:p></o:p>
Set wbPR =Workbooks("FinalPAYROLL.xlsm")<o:p></o:p>
***** Set wbRec =Workbooks("I:\Rosy's\Pay Roll\2017 Pay Records.xlsm")<o:p></o:p>
' wbRec.Unprotect<o:p></o:p>
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Hi & welcome to MrExcel
How about
Code:
Sub SingleRecord()
Rem Records payroll data inrecords file
Static bFileopen As Boolean
Dim wbRec As Workbook
Dim wbPR As Workbook
Set wbRec = Workbooks.Open("I:\Rosy's\Pay Roll\2017 Pay Records .xlsm")
Set wbPR = Workbooks("FinalPAYROLL.xlsm")
' wbRec.Unprotect
PS in your code you have a space between records & .xlsm when you open it, but not when you try to set wbRec
 
Upvote 0
Did you try the code I supplied, or just modified yours?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top