Userform Label automatically displays information from several textboxes

dylanrose

New Member
Joined
Mar 29, 2014
Messages
6
Hi to all,

Userform

I would like to ask if there is a possible way for a Label to display information that are based on multiple textboxes?
All the information are based on the textboxes and listboxes that are in the userform and will be displayed on the Label (label16)
 
Label to display information that are based on multiple textboxes?...

I'm not sure what you mean by based on multiple textboxes. However, if you want to concatenate the two textboxes you can try the following:

Code:
Label16 = TextBox1 & TextBox2

Or if you want to populate the label on condition then try this:
Code:
If TextBox1 = "Test" And TextBox2 = "Test2" Then
    Label16 = "We are testing"
End If
 
Upvote 0
I'm not sure what you mean by based on multiple textboxes. However, if you want to concatenate the two textboxes you can try the following:

Code:
Label16 = TextBox1 & TextBox2

Or if you want to populate the label on condition then try this:
Code:
If TextBox1 = "Test" And TextBox2 = "Test2" Then
    Label16 = "We are testing"
End If


Hi Gavin T.
Thanks for answering my question.

Should I put the code in a change event? or where should I put the code?
Also, Yes, I would like to concatenate the textboxes but separated by a comma. How should I code it?
I tried using:

Code:
Label16.Caption = TextBox1.Text & ", " & TextBox2.Text

But to no avail, it gives me error. Is there a possible workaround for this?
Thanks Gavin T!
 
Upvote 0
Should I put the code in a change event? or where should I put the code?...

When would you like the label to update? You could put it in both of the textboxes change events as follows:

Code:
Private Sub TextBox1_Change()
    Label16.Caption = TextBox1.Text & ", " & TextBox2.Text
End Sub

Private Sub TextBox2_Change()
    Label16.Caption = TextBox1.Text & ", " & TextBox2.Text
End Sub

Your code to concatenate is fine. Make sure you're putting the code in the forms private module. You can get there by hitting F7 when your in the form design view.

Good Luck!
 
Upvote 0
When would you like the label to update? You could put it in both of the textboxes change events as follows:

Code:
Private Sub TextBox1_Change()
    Label16.Caption = TextBox1.Text & ", " & TextBox2.Text
End Sub

Private Sub TextBox2_Change()
    Label16.Caption = TextBox1.Text & ", " & TextBox2.Text
End Sub

Your code to concatenate is fine. Make sure you're putting the code in the forms private module. You can get there by hitting F7 when your in the form design view.

Good Luck!


Gavin T,
I want it to automatically update as I click my comboboxes, listboxes and type in in textboxes. Is there a way that I can send you my excel workbook so that you could see what I have so far? I can't seem to attach my file here.

Thanks so much Gavin T!
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top