ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Text Box - Control Source (https://www.excelbanter.com/excel-programming/384335-text-box-control-source.html)

kirkm[_6_]

Text Box - Control Source
 

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

Peter T

Text Box - Control Source
 
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



"kirkm" wrote in message
...

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





All times are GMT +1. The time now is 03:10 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com