Run time Error 9:Subscript out of range (1 Viewer)

SweetMisery

New member
Local time
Today, 13:36
Joined
Jul 6, 2012
Messages
4
I am new to VBA codes and programming and I need your help desperately because I need this report done asap. :(

I am making a simple data sheet in excel. I have sheets which contain supplier's information. I have made a home page which summarizes all the supplier names with hyperlinks to each supplier sheet. In the supplier sheet, I have set activex buttons: Previous Page, Home Page, Next Page. Here's the vba code I'm Using:

Private Sub CommandButton1_Click()
Worksheets("NAFFCO").Activate
End Sub

Private Sub CommandButton2_Click()
Worksheets("Home").Activate
End Sub

Private Sub CommandButton3_Click()
Worksheets("SFFECO").Activate
End Sub

but when I ran the vba code, I get an error message "Run time Error 9: Subscript out of range" on some of the sheets. I have used the same vba codes for all the 15 sheets but 3 sheets are giving me headache. :banghead:

Please reply with the corrections. Thanks!
 

vbaInet

AWF VIP
Local time
Today, 10:36
Joined
Jan 22, 2010
Messages
26,374
The sheet names are wrong are do not exist in the Active Workbook. Check them again.

And it's better you qualify your reference to the sheets. E.g.
Code:
ThisWorkbook.Worksheets("SheetNme")
 

SweetMisery

New member
Local time
Today, 13:36
Joined
Jul 6, 2012
Messages
4
Hi vbaInet,

Thanks for your immediate reply. I rechecked the sheet names and you were correct! that was the error. It appeared that it's not accepting the sheet names but after I changed it and made sure they're accurate, it started working! I'm so happy! Thank you so mch!!
 

vbaInet

AWF VIP
Local time
Today, 10:36
Joined
Jan 22, 2010
Messages
26,374
You're welcome!

And welcome to the forum by the way.
 

Users who are viewing this thread

Top Bottom