User Form Data Validation

  • Thread starter Thread starter MBlake
  • Start date Start date
M

MBlake

How, Please could someone point me to a good tutorial on data validation for
user forms?. I have a workbook that uses the INDIRECT method to restrict
options dependant on the first selection. I want to create a user form for
data entry, if I use the Excel data form from the menu bar, the data
validation is not carried across.

A url to advice would be great,
Thanks,
Mickey
 
Are you using a combobox on that userform?

Instead of using =indirect() in the userform, I just used code to point at that
other range.

I put two comboboxes and two commmand buttons (ok/cancel) on a userform.

This is the code I had behind it:

Option Explicit
Private Sub ComboBox1_Change()

Dim myList As Variant
Select Case LCase(Me.ComboBox1.Value)
Case Is = "$a$1": myList = Worksheets("sheet1").Range("b1:b10").Value
Case Is = "$a$2": myList = Worksheets("sheet1").Range("c1:c10").Value
Case Is = "$a$3": myList = Worksheets("sheet1").Range("d1:d10").Value
End Select

With Me.ComboBox2
.List = myList
.ListIndex = -1
End With

End Sub
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
With Me.ComboBox1
.Style = fmStyleDropDownList
.List = Worksheets("sheet1").Range("a1:a3").Value
End With

Me.ComboBox2.Style = fmStyleDropDownList
End Sub

Maybe you could play with this and get a few ideas???
 
Back
Top