Page 1 of 1

Run-time error '9': - Subscript out of range

Posted: Wed Dec 17, 2014 8:32 am
by KapilSoni
Hi,

I'm a novice programmer (kind of make shift), please ignore accordingly.

I wrote codes using this logic, it works in one, but fails in other macro file. Error I get is:

Run-time error '9':
Subscript out of range


Code:

Code: Select all

Dim wbPending, wbAccept, wbReject As Workbook
.. some lines ..

Code: Select all

Set wbPending = ActiveWorkbook
wbPending.Worksheets("PendingTransaction").Range("C2").Value = "TESTING ..."
The above error message appears on line:- wbPending.Worksheets("PendingTransaction").Range("C2").Value = "TESTING ..."


Can anyone help on the same ?

I guess, I've done something very silly :?
:crazy:

Re: Run-time error '9': - Subscript out of range

Posted: Wed Dec 17, 2014 9:27 am
by KapilSoni
P.S.: I was able to overcome this issue by adding line

Code: Select all

wbPending.Activate
. However, I wonder the reason behind this !!!