PDA

View Full Version : unload userform if greater than certain row



wilg
02-05-2012, 09:24 AM
I have a userform that will activate if in column a. However I do not want it to activate if it is below a certain row.

eg range("ak301").value which gives me the row number I want the userform to stop activating at.

Is there a way to use an if statement to include if below row ak301's value (eg row 354) then unload userform or exit?


my userform is called Names1


Private Sub UserForm_Initialize()
ComboBox1.RowSource = "COMPLETE_NAME"
ComboBox1.Value = ActiveCell.Value
With ComboBox1
.SelStart = 0

.SelLength = Len(ComboBox1)

End With
End Sub

wilg
02-05-2012, 09:38 AM
I use the selection change to initialize userform below. Would this be where I put code?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If ActiveCell.Column = 1 Then
Names1.Show

End If
End Sub

shrivallabha
02-05-2012, 10:45 AM
I use the selection change to initialize userform below. Would this be where I put code?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If ActiveCell.Column = 1 Then
Names1.Show

End If
End Sub
Something like:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 1 And Target.Row < Range("AK301").Value Then
Names1.Show
End If
End Sub