Runtime error 9

MAMIBUSSOL

Board Regular
Joined
Jun 2, 2011
Messages
95
Hi

what might I be missing with this code

SETAREA - procedure within the same module
PASSWEEKNO - assigned using application.inputbox - value = 0
FILE0 - contains "TEST"
WORKBOOKS(WAGES2) - contains "2009-06-12.xls"
WORKBOOKS(FILE1) - contains "test 2009.xlsm

all of the variable are containing the correct information, however if I highlight

WORKBOOKS(FILE1) - I get <subscript out of range>

Code:
[SIZE=1]PASSWEEKNO = Application.InputBox("ENTER PAYSLIP NUMBER ?", "PRINT PAYSLIP", Type:=1)
[/SIZE]


Code:
[SIZE=1]SETAREA PASSWEEKNO, FILE0, Workbooks(WAGES2), [B]Workbooks(FILE1)
[/B][/SIZE]

Code:
[SIZE=1]Sub SETAREA(WEEKNO As Variant, Sheet1 As Variant, WAGES As Workbook, FILE As Workbook)
[/SIZE]

I need to tie up to:-

PASSWEEKNO - WEEKNO
FILE0 - SHEET1
WORKBOOKS(WAGES2) - WAGES AS WORKBOOK
WORKBOOKS(FILE1) - FILE AS WORKBOOK
 
Last edited:

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
The issue should be your workbook references. they variables "WAGES2" and "FILE1" shoud be stored as strings, also the workbooks need to be opened. if they are not opened then you need to change your the Sub "SETAREA" types from "workbook" to String and then have the sub open those workbooks.
 
Upvote 0

Forum statistics

Threads
1,215,465
Messages
6,124,978
Members
449,200
Latest member
Jamil ahmed

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