-
Solved: Listbox, should be simple!
Any help would be welcome.
I have a userform with one listbox populated with a named range (Names).
also on the form are 2 textboxes for the user to input 2 numbers.
When the user clicks OK button the selected listbox name should be looked up against the named range on the worksheet and the 2 textbox values written to the next 2 adjacent columns.
Thanks Pete
-
[vba]Private Sub ListBox1_Click()
Dim r As Range
Dim i As Long
i = ListBox1.ListIndex + 1
Set r = Range(ListBox1.RowSource)
r.Cells(i, 1).Offset(, 1) = TextBox1
r.Cells(i, 1).Offset(, 2) = TextBox2
End Sub
[/vba]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
-
Thanks for your time, just what I wanted
Pete
-
Glad to help.
You can mark you threads solved using the Thread Tools dropdown
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules