Data Entry Form
Thanks so much.
I wrestled with this one for a couple of days, and now Im faced with two
options. I plan on adding up to twenty columns, and organizing the form with
some multipages. Both approaches will work for this, but for my own
edification, what are the pros and cons of the two?
Thanks again,
Steve
"Dave Peterson" wrote:
Your combobox can have more than one column in it (and you can hide as many
columns as you want!).
So once you fill the combobox with the values, you can use the combobox's list
to get the associated values without going back to the worksheet.
I put a commandbutton, 2 textboxes, and a combobox on a userform. This was the
code behind the userform:
Option Explicit
Private Sub ComboBox1_Change()
With Me.ComboBox1
If .ListIndex < 0 Then
'do nothing
Else
Me.TextBox1.Value = .List(.ListIndex, 1)
Me.TextBox2.Value = .List(.ListIndex, 2)
End If
End With
End Sub
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim myRng As Range
With Worksheets("sheet1")
Set myRng = .Range("a1:C" & .Cells(.Rows.Count, "A").End(xlUp).Row)
End With
With Me.ComboBox1
.ColumnCount = 3
.ColumnWidths = "33;0;0"
.RowSource = myRng.Address(external:=True)
End With
Me.ComboBox1.Style = fmStyleDropDownList
End Sub
Steve wrote:
I am trying to develop a user form for updating some records. I would like
to be able to use a combo box to select a field in column A. Then have two
text boxes populated with the remaining record (i.e. column B & C). I have
the combo box working, but I€„¢m having trouble figuring out how to index &
offset from the first column.
I know I could use Excel€„¢s data form, but it doesn€„¢t have a combo box and I
plan on building upon my form for other future use. Besides, it€„¢s too much
fun trying to make my own : )
Thanks in advance,
Steve
--
Dave Peterson
|