simora
01-05-2010, 10:33 PM
On my Excel userForm I am populating a combobox from worksheet names at Private Sub UserForm_Initialize and then populating a ListBox with names from the spreadsheet so that some textboxes are filled In like
Private Sub ListBox1_Change()
Set SourceRange = Range(ListBox1.RowSource)
TextBox1 = ListBox1.Value ' Column A
TextBox2 = SourceRange.Offset(ListBox1.ListIndex, 1).Resize(1, 1).Value ' Column B
TextBox3 = SourceRange.Offset(ListBox1.ListIndex, 2).Resize(1, 1).Value ' Column C
The ComboBox selection sets the sheet that I then show the RowSource like this Using Select / Case
Case "Sheet2"
With Sheet2
ListBox1.RowSource = Range(.Range("A4"), .Cells(Rows.Count, "A").End(xlUp)).Address(, , , True)
End With
This all works up to this point. Now the problem!
How do I post the contents of additional textboxes back to the Worksheet based on the name selected in the Listbox.
I want to post the values of TextBox4, - TextBox8 to the worksheet. TextBox4 is Column D, 5 is E etc...etc....
Any assistance, code etc...... apreciated.
Thanks
Private Sub ListBox1_Change()
Set SourceRange = Range(ListBox1.RowSource)
TextBox1 = ListBox1.Value ' Column A
TextBox2 = SourceRange.Offset(ListBox1.ListIndex, 1).Resize(1, 1).Value ' Column B
TextBox3 = SourceRange.Offset(ListBox1.ListIndex, 2).Resize(1, 1).Value ' Column C
The ComboBox selection sets the sheet that I then show the RowSource like this Using Select / Case
Case "Sheet2"
With Sheet2
ListBox1.RowSource = Range(.Range("A4"), .Cells(Rows.Count, "A").End(xlUp)).Address(, , , True)
End With
This all works up to this point. Now the problem!
How do I post the contents of additional textboxes back to the Worksheet based on the name selected in the Listbox.
I want to post the values of TextBox4, - TextBox8 to the worksheet. TextBox4 is Column D, 5 is E etc...etc....
Any assistance, code etc...... apreciated.
Thanks