MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Data Input Box

Posted by Barry Divers on July 09, 2001 6:32 AM

Hello everyone
I would like to have a userform displaying a list box and some text boxes. The list box is to contain a list of operators that have been input into a single column. The text boxes need to transfer the data that is input to them to specific cells on pressing an OK command button. Can anyone help me out with the code

Posted by Ben O. on July 09, 2001 7:07 AM

Hey Barry,

To get your listbox to display the data you want, click on the listbox and find RowSource in the Properties Window. Enter the source of the listbox's information here, like 'Sheet1'!A2:A50. Alternately, you could put this statement in your UserForm_Initialize() statement:

Listbox1.Rowsource = "'Sheet1'!A2:A50"

When you create your OK button, name it OKbutton. Then use code like this to transfer the values of the text boxes to cells:

Private Sub OKbutton_Click()

Sheets("Sheet1").Range("B1") = TextBox1.Value
Sheets("Sheet1").Range("B2") = TextBox2.Value

End Sub

Let you know if you have any further questions, or if you'd like something clarified.


Posted by Barry Divers on July 11, 2001 8:10 AM

Thanks Ben
Thats great for starters whats more it works. In addition to what you have told me I would like some text boxes where I can input data and the data should be transferred to the relevant cells in a similar way to the list box scenario can you help some more.