Text Box - Control Source

K

kirkm

I have a text box control on a userform

I'd like the text box to display the contents of a worksheet range A2-
A10.

It's not clear where this goes in the text box properties.

What is 'Control Source' and what value goes there? Help gives me a
listbox example. Also where does the Worksheet name go?

Thanks - Kirk
 
P

Peter T

Hi Kirk,

ControlSource only accepts a single location or cell, so you can't use that
for your multi-cell source.

Private Sub UserForm_Click()
' probably in the initialize event
' set the tb's MultiLine property to true
Dim i&, s$
For i = 2 To 10
s = s & ActiveSheet.Cells(i, 1)
If i < 10 Then s = s & vbCr
Next
Me.TextBox2.Text = s
End Sub

ControlSource is normally a two way link, if that's what you need then look
at the textbox AfterUpdate event to write changes back to cells, might need
the Split function.

Perhaps a ListBox might better suit your needs to link multi-cells with
RowSource.

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top