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

clares

Well-known Member
Joined
Mar 14, 2002
Messages
557
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
 

Some videos you may like

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

bat17

Well-known Member
Joined
Aug 15, 2003
Messages
1,470
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
 

clares

Well-known Member
Joined
Mar 14, 2002
Messages
557
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
 

Watch MrExcel Video

Forum statistics

Threads
1,095,267
Messages
5,443,436
Members
405,235
Latest member
1Thess521

This Week's Hot Topics

Top