"Run Time error '9' - Subscript out of range"

clares

Well-known Member
Joined
Mar 14, 2002
Messages
557
Hi All

I am stepping through my code and I get to this line:

Set HelpSheet = ThisWorkbook.Sheets(HelpSheetName)

and it gives an error message:

"Run Time error 9 - Subscript out of range".

I have had a look at the help file, but dont really understand it.

Thanks in advance for any help

Kindest Regards
 
Yes certainly. Here you go:

Option Explicit
Dim TopicCount As Integer
Dim CurrentTopic As Integer
Dim HelpSheet As Worksheet

Const AppName As String = "Clares Automated Pricing System"
Const HelpSheetName As String = "HelpSheet"
Const HelpFormCaption As String = AppName

Private Sub Help()
FormHelp.Show
End Sub

Private Sub UserForm_Initialize()
'Executed before the form is shown
Dim Row As Integer
Set HelpSheet = ThisWorkbook.Sheets(HelpSheetName)
TopicCount = Application.WorksheetFunction.CountA(HelpSheet.Range("A:A"))
For Row = 1 To TopicCount
ComboBoxTopics.AddItem HelpSheet.Cells(Row, 1)
Next Row
ComboBoxTopics.ListIndex = 0
CurrentTopic = 1
UpdateForm
End Sub
 
Upvote 0

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
I think that you need to use Public declarations for the form to be able to see them
Code:
Option Explicit
Public TopicCount As Integer
Public CurrentTopic As Integer
Public HelpSheet As Worksheet

Public Const AppName As String = "Clares Automated Pricing System"
Public Const HelpSheetName As String = "HelpSheet"
Public Const HelpFormCaption As String = AppName

HTH

Peter
 
Upvote 0
Thanks now have got it working. I initially had it in the personal workbook, however I have now placed it in the workbook that I am working in and works ok. Thanks for you patience and help

Kindest Regards all
 
Upvote 0

Forum statistics

Threads
1,213,531
Messages
6,114,167
Members
448,554
Latest member
Gleisner2

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