+ Reply to Thread
Results 1 to 4 of 4

VBA Line to Send Userform Info to Parent Userform Textbox

  1. #1
    Registered User
    Join Date
    07-15-2013
    Location
    Arizona
    MS-Off Ver
    Excel 2016
    Posts
    64

    VBA Line to Send Userform Info to Parent Userform Textbox

    Hello Forum,

    Thanks in advance for your help.

    I have a userform (call it "Child") that has a multitude of listboxes and a few textboxes that I'd like to pop up from a primary userform (call it "Parent"), allow the user to make their selections and entries in Child, then send those entries back to a specific textbox (call it "TxtBx") on the the Parent userform.

    I already have code (thanks to this Forum!) that takes the multiselect listbox selections and textbox entries from Child and combines them into a Dim text string called "Selections". Currently it's set up to populate a specific cell in my Excel spreadsheet:
    Please Login or Register  to view this content.
    My requirements have changed and now I need it to populate the Parent textbox as described above, which I will then send to the spreadsheet cell.

    Is this possible and, if so, how do I modify this text destination coding to accomplish this?

    Again, appreciate your time and help.

    Regards,
    Chris

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA Line to Send Userform Info to Parent Userform Textbox

    Hello excelforumkeys,

    If Selections has been declared a Public variable in a VBA Module then you can simply assign it to the UserForm's text. In this example UserForm1 represents the "Parent" form.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    07-15-2013
    Location
    Arizona
    MS-Off Ver
    Excel 2016
    Posts
    64

    Re: VBA Line to Send Userform Info to Parent Userform Textbox

    Hi and thanks for the quick response Leith.

    This is where my ignorance shines. Couple questions:

    "Selections" is set within a Private Sub for a command button as:
    Please Login or Register  to view this content.
    How do declare it as a Public Variable in a module? Do I simply change it to:
    Please Login or Register  to view this content.
    and move it to the top of that module? And will it still work in the command button coding?

    Also, I should have mentioned that my "Parent" userform is a multipage userform and the textbox is on page 3. Knowing that, would the proper code for assigning to the textbox be:
    Please Login or Register  to view this content.
    Again, your help is appreciated. Chris

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA Line to Send Userform Info to Parent Userform Textbox

    Hello excelforumkeys,

    All code in a UserForm is only available to the UserForm. Even if you have declared Selections as Public at the top of the UserForm.

    By placing a variable in a standard VBA Module and declaring it Public, it becomes available to all code in your VBA Project. So by declaring Selections in a VBA Module, you can access it from any UserForm or anywhere in your VBA code.

    Example
    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. [SOLVED] Excel 2007, Userform Textbox Date Format and Calendar Control Userform
    By riffology in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-03-2014, 06:18 PM
  2. [SOLVED] Pass Value of combobox selected in Userform as input to textbox of other userform
    By Pradeepg in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-29-2013, 10:32 AM
  3. [SOLVED] Open a userform from a userform, but preserve the info in the original userform
    By jfoerch in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-25-2013, 02:38 PM
  4. Userform Textbox updating a another userform textbox (im stuck!!)
    By wapwap in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-31-2011, 02:56 PM
  5. userform: trasnferring textbox value to label field in next userform
    By brillison in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-17-2008, 08:18 PM

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