+ Reply to Thread
Results 1 to 22 of 22

Userform Label to display information from several textboxes

  1. #1
    Registered User
    Join Date
    03-24-2013
    Location
    Quezon City, Philippines
    MS-Off Ver
    Excel 2010/2013
    Posts
    83

    Userform Label to display information from several textboxes

    Hi to all,

    Userform help

    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)

    Please see attached. Thanks!

    userform.png

    **Cross reference link: http://www.mrexcel.com/forum/excel-q...textboxes.html

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    12,974

    re: Userform Label to display information from several textboxes

    Label.Caption = Textbox1.Text & vbCrLf & Textbox2.text
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    03-24-2013
    Location
    Quezon City, Philippines
    MS-Off Ver
    Excel 2010/2013
    Posts
    83

    re: Userform Label to display information from several textboxes

    Quote Originally Posted by protonLeah View Post
    Label.Caption = Textbox1.Text & vbCrLf & Textbox2.text
    Thanks protonLeah!

    What if for example, based on the picture I have screenshot, The offertype combobox has 2 options (ie. Rent/Buy):

    My initial code is that

    Please Login or Register  to view this content.
    But to no avail I can't use this one because it's not working and I also need to link the other comboboxes and textboxes to the label.

    Thanks for helping me!

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    12,974

    re: Userform Label to display information from several textboxes

    You cannot create your own change event. You must use the built-in events.
    Without a workbook I'm guessing. You need change events for each of the controls you want displayed in the label.

    For example, when combobox1 changes:
    sub Combobox1_Change()
    Label1.Caption = Label1.Caption & vbCrLf & Combobox1.text
    End Sub

    It will be similar for each combo/text box. As you change each control, the value will be appended to the label caption.
    Last edited by protonLeah; 05-11-2014 at 02:58 PM.

  5. #5
    Registered User
    Join Date
    03-24-2013
    Location
    Quezon City, Philippines
    MS-Off Ver
    Excel 2010/2013
    Posts
    83

    re: Userform Label to display information from several textboxes

    Hi protonLeah,

    Thank you for replying to my post.
    Please see attached excel workbook. I'm having problems to when I tried your code. it always goes down. I mean is vbCrLf same with Enter? because it seems that it makes a multiline. What if I wanted just a space or a comma?

    Thanks protonLeah!

  6. #6
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    12,974

    re: Userform Label to display information from several textboxes

    I changed the name of the label to SummaryLabel and added the following to several of the listboxes, not all:
    Please Login or Register  to view this content.
    Replace RegionList with the appropriate listbox name.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    03-24-2013
    Location
    Quezon City, Philippines
    MS-Off Ver
    Excel 2010/2013
    Posts
    83

    re: Userform Label to display information from several textboxes

    Quote Originally Posted by protonLeah View Post
    I changed the name of the label to SummaryLabel and added the following to several of the listboxes, not all:
    Please Login or Register  to view this content.
    Replace RegionList with the appropriate listbox name.

    Hi protonLeah! Thanks for helping me out. If I may ask, is there a way that vbCrLf be just a space? not an enter?
    Also when I test the workbook, whenever I select any "region", "city" or "area", it just adds up to the label. Is there a way that when for example I select "Region 1" then "City 1" then "Area 1", then I mistakenly selected "Region 1" that it must be "Region 2" , the "Regions", "Cities" and "Areas" in the label will be cleared and automatically be filled by the region I selected?

    Thanks again protonLeah! so sorry for the late reply.

  8. #8
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    12,974

    re: Userform Label to display information from several textboxes

    I have modified the code to clear the label whenever the REGIONS list is selected and I replaced the vbCrLf with commas instead; I don't think using a space as a separator is a good idea since so many of the regions, cities and areas are multiple words separated by spaces.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    03-24-2013
    Location
    Quezon City, Philippines
    MS-Off Ver
    Excel 2010/2013
    Posts
    83

    re: Userform Label to display information from several textboxes

    Hi protonLeah!

    the code that you modified works brilliantly. I'd like to ask what does this code do? I mean could you explain further this one:

    Please Login or Register  to view this content.
    Questions:
    1. Because my knowledge is still not enough and you use this code and called it in the userform_initialize() , right?
    2. Also, the (1 To 3) can that be change to (1 To any #)?


    Sorry if I have a lot of questions raised. It is because I found you're answer beyond the scope of my comprehension and it really adds up to my knowledge. I would gladly appreciate if I could learn more from you.

    I still have some questions but I think these questions first I need to know so that maybe, I can try to do this to in my workbook. :D

    Thanks so much protonLeah!

  10. #10
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    12,974

    re: Userform Label to display information from several textboxes

    The ENUM is another way of declaring constants. For Instance, instead of:

    Enum FLS
    Regions = 1
    Cities
    Areas...
    End Enum

    I could have coded:
    Const Regions As Long = 1
    Const Cities As Long = 2
    Const Areas As Long = 3, etc.

    In the ENUM structure, I assigned the first item a value of 1, and VBA automatically incremented those following by 1 (in this case), but they could have been assigned other values.

    I created a variable for each of the listboxes, comboboxes and textboxes on the form; though, currently, the code only used the first three.

    The line: Dim SummaryArray(1 To 3) As String, creates a three element array (one for each listbox).

    When you click a listbox, say, City, the code:
    SummaryArray(Cities) = CityList
    will load the selected city into array element #2 because Cities is the second variable in the ENUM.

    The selected values are copied to the SummaryLabel caption in the AreaList_Click code using:

    SummaryLabel.Caption = Join(SummaryArray, ", ") which just joins the elements into a single comma separated string.
    Last edited by protonLeah; 05-13-2014 at 08:34 PM.

  11. #11
    Registered User
    Join Date
    03-24-2013
    Location
    Quezon City, Philippines
    MS-Off Ver
    Excel 2010/2013
    Posts
    83

    re: Userform Label to display information from several textboxes

    I see .. Now I get it!

    Thank you so much protonLeah for your help.
    Is it okay if I have another questions posted here, is it okay if I send you a message or post the link of my thread in your page here?

    Thanks again protonLeah! :D

  12. #12
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    12,974

    re: Userform Label to display information from several textboxes

    If the question is related to this thread, please post the questions here; if it's a completely new question, please start another thread and a link to this one.
    Last edited by protonLeah; 05-13-2014 at 08:33 PM.

  13. #13
    Registered User
    Join Date
    03-24-2013
    Location
    Quezon City, Philippines
    MS-Off Ver
    Excel 2010/2013
    Posts
    83

    re: Userform Label to display information from several textboxes

    Quote Originally Posted by protonLeah View Post
    If the question is related to this thread, please post the questions here; if it's a completely new question, please start another thread and a link to this one.
    protonLeah, I did have a problem. awhile ago, my code is working properly but now, it's not. My laptop had a split screen and i didn't have a backup and then when I tried to work with the file that I originally have (i.e. i get it from here as DL file), it doesn't work properly anymore.

    Please Login or Register  to view this content.
    I can't seem to make this one work. The one in the red but when I put the code after SummaryLabel.Caption = Join(SummaryArray, ", "), it works but it deletes the other information.

    Thanks protonLeah!

  14. #14
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    12,974

    re: Userform Label to display information from several textboxes

    Maybe:
    Please Login or Register  to view this content.
    Also, you can delete occurrences of:
    SummaryNdx = WorksheetFunction.Count(SummaryArray())
    I never used it but forgot to delete it myself.
    Last edited by protonLeah; 05-15-2014 at 01:51 AM.

  15. #15
    Registered User
    Join Date
    03-24-2013
    Location
    Quezon City, Philippines
    MS-Off Ver
    Excel 2010/2013
    Posts
    83

    re: Userform Label to display information from several textboxes

    Hi protonLeah!


    Thank you! Already working.

    1.) What about in the Land Size or Building Size, how can I add "sqm Lot" and "sqm Floor", respectively?

    2.) How can I hide the commas if there's no value in a textbox? for example, I didn't select "Rent" or "Buy" and it won't display the any commas. Or for example too, I didn't input anything in the textboxes or in the comboboxes and just click "Regions, "Cities" or "Area" but it won't display any commas (,).


    Thank you so much protonLeah!
    Last edited by dylanrose; 05-15-2014 at 04:55 AM.

  16. #16
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    12,974

    re: Userform Label to display information from several textboxes

    1. Are you saying that you want something like 12,000 sqm lot put in the label? If so, supposing that the building size textbox is still named textbox2, then you need something like
    SummaryArray(BlgSize) = textbox2.text & " sqm lot"
    2. I'll have to wait for tomorrow for that one.

  17. #17
    Registered User
    Join Date
    03-24-2013
    Location
    Quezon City, Philippines
    MS-Off Ver
    Excel 2010/2013
    Posts
    83

    re: Userform Label to display information from several textboxes

    I see. Okay. I'll try that one protonLeah for my question #1.

    For my question #2 , i'll wait for your answer but I'll try to code too on how it will hide the commas.



    Thanks so much protonLeah for your help! Really appreciate it!

    Sent from my SM-N900 using Tapatalk

  18. #18
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    12,974

    re: Userform Label to display information from several textboxes

    Each text and list box need to be modified with:

    Please Login or Register  to view this content.
    Then add this Sub in the form's module
    Please Login or Register  to view this content.
    Last edited by protonLeah; 05-16-2014 at 06:26 PM.

  19. #19
    Registered User
    Join Date
    03-24-2013
    Location
    Quezon City, Philippines
    MS-Off Ver
    Excel 2010/2013
    Posts
    83

    Re: Userform Label to display information from several textboxes

    Quote Originally Posted by protonLeah View Post
    Each text and list box need to be modified with:

    Please Login or Register  to view this content.
    Then add this Sub in the form's module
    Please Login or Register  to view this content.


    Hi protonLeah,

    I just need to put Build Summary right? After putting the Sub in the form's module? I tried it and it works like a charm!

    Last 2 question(s) for this thread protonLeah:
    1. Regarding the Subtype, how can I link it to the Bedrooms?
    For example,
    1. If Loft is selected in Subtype then the Bedroom will be just blank
    2. If Studio is selected then the bedroom will be 1
    3. If Penthouse is selected then just leave the bedroom blank
    4. if 1 bedroom is selected then 1
    5. if 2 bedroom is selected then 2
    6. and so on until 6 bedroom
    and then in the summary label the "bedroom" will be put (i.e. just like what you did in the Building size and land size where in "sqm Lot" is displayed in the summary label). How should I code it? or What will be the code that I need to use or modify?

    2.) For the Floor, how can I add the suffixes st floor, nd floor, rd floor, and th floor? I did this one without coding, just vlookup function. But I really would like to have it as coded as much as possible so that the workbook won't be prone to so much human error.

    ----------------------------------------------------------------------------------------------------------------------------------------

    protonLeah, I have another question, it's related to this thread but it's about radio buttons and disabling some radio buttons, comboboxes, textboxes, and etc. I'll make another thread and I'll reference this thread to the thread I'll be posting.

    Thanks so much protonLeah for your help!
    I'll mark this one now as solved.
    Last edited by dylanrose; 05-17-2014 at 08:25 AM.

  20. #20
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    12,974

    Re: Userform Label to display information from several textboxes

    I have made several additions to the form code:
    Attached Files Attached Files

  21. #21
    Registered User
    Join Date
    03-24-2013
    Location
    Quezon City, Philippines
    MS-Off Ver
    Excel 2010/2013
    Posts
    83

    Re: Userform Label to display information from several textboxes

    Quote Originally Posted by protonLeah View Post
    I have made several additions to the form code:
    protonLeah, I'm having a problem here:

    Please Login or Register  to view this content.
    it says that Compile error: Can't find project or library and then the text that I have colored in red is highlighted. Do I need to insert a Dim ... As Variant? or what should I change?

    Thanks protonLeah!

  22. #22
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    12,974

    Re: Userform Label to display information from several textboxes

    Mid is a standard VBA function. In the VBA check the Tools/References for missing libraries
    * Or just replace the Floor_Change sub with: *
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Search worksheet for data in multiple textboxes in userform and display in another workshe
    By SierraKilo78 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-23-2013, 09:59 AM
  2. [SOLVED] Taking information from worksheet and transferring it to Userform textboxes
    By Spritz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-04-2013, 12:08 PM
  3. Replies: 6
    Last Post: 10-10-2012, 01:54 PM
  4. Textboxes within Userform to display info based on combobox selection
    By alter54 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-28-2012, 12:40 PM
  5. userform to count cell colours and display in textboxes
    By AGrace in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-31-2011, 09:39 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1