For the code I gave you yesterday, you have to click the
Apply button both to retrieve the cell values and place
them into the text boxes as well as to paste the text box
values to the worksheet. It depends upon whether you
selected a name from the list or typed a new one into the
window. If that's what you were doing and it still didn't
work then your setup is somehow different from mine.
However, never mind yesterday's code. I wrote an update
(see below) that it will automatically retrieve the cell
values and place them into the text boxes without having
to click the Apply button. Just select a name from the
list. The Apply button is needed only to paste new data to
the worksheet into a new row.
My trials confirmed that this works. Make sure that you
create the UF as I described yesterday. The worksheet data
as per the current setup starts in Cell A5 and continues
down for as long as you like. Miscellaneous data is placed
in the adjacent five columns (Columns B to F). Correct for
word wrap.
'Module level declarations
Dim Rng As Range, Rw As Long
Private Sub UserForm_Initialize()
Rw = Range("A65536").End(xlUp).Row
Set Rng = ActiveSheet.Range(Cells(5, 1), Cells(Rw, 1))
ComboBox1.RowSource = Rng.Address
End Sub
Private Sub ApplyBtn_Click()
Dim i As Long
Cells(Rw + 1, 1).Value = ComboBox1.Value
For i = 1 To 5
Cells(Rw + 1, i + 1) = Controls("TextBox" & i).Text
Next
Rw = Range("A65536").End(xlUp).Row
Set Rng = ActiveSheet.Range(Cells(5, 1), Cells(Rw, 1))
ComboBox1.RowSource = Rng.Address
End Sub
Private Sub ComboBox1_DropButtonClick()
Dim i As Integer, ii As Integer
With ComboBox1
If .ListIndex = 0 Then
For ii = 1 To 5
Controls("TextBox" & ii).Text = Cells(Rng
(.ListIndex + 1).Row, ii + 1)
Next
End If
End With
End Sub
Private Sub CommandButton1_Click()
Unload Me
End Sub
Regards,
Greg
-----Original Message-----
This works to enter the persons information into the
worksheet, but I
want to have it now, so that when I choose the name from
the list, that
the information entered into those other cells
automatically shows up
in the other text boxes
---
Message posted from http://www.ExcelForum.com/
.