pcsparky
01-18-2009, 06:08 AM
I've created a Userform and I'd like to use the variable startRow from the first Sub in the next sub (both are in the same form code box) but can't work out how despite trawling the net for ages. I just don't understand VBA very well at the moment as I'm just learning.
I get the Runtime error 1014 at endCell = Cells(startRow, 4).End(xlDown).Row as there is no value.
Any help please.
Sub options()
Dim startRow As Integer
If TrainingType.OptionButton1.Value = True Then
startRow = 8
handlerType = "GPD Handlers"
End If
End Sub
__________________________________________________
Public Sub UserForm_Activate()
Dim handlerName As String
Dim counter As Integer
Dim endCell As Integer
Dim startRow As Integer
ListBox1.Clear
Sheets("Dog and Handler Data").Activate
endCell = Cells(startRow, 4).End(xlDown).Row
For counter = startRow To endCell
handlerName = Cells(startRow, 4)
ListBox1.AddItem (handlerName)
startRow = startRow + 1
Next counter
End Sub
I get the Runtime error 1014 at endCell = Cells(startRow, 4).End(xlDown).Row as there is no value.
Any help please.
Sub options()
Dim startRow As Integer
If TrainingType.OptionButton1.Value = True Then
startRow = 8
handlerType = "GPD Handlers"
End If
End Sub
__________________________________________________
Public Sub UserForm_Activate()
Dim handlerName As String
Dim counter As Integer
Dim endCell As Integer
Dim startRow As Integer
ListBox1.Clear
Sheets("Dog and Handler Data").Activate
endCell = Cells(startRow, 4).End(xlDown).Row
For counter = startRow To endCell
handlerName = Cells(startRow, 4)
ListBox1.AddItem (handlerName)
startRow = startRow + 1
Next counter
End Sub