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:

Some videos you may like

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

bstory84

Active Member
Joined
Oct 31, 2011
Messages
403
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,215
Messages
5,594,883
Members
413,947
Latest member
gizmolucy

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
Top