+ Reply to Thread
Results 1 to 5 of 5

How to access Userforms created with "add" ? How to add some text inside ?

  1. #1
    Registered User
    Join Date
    08-20-2021
    Location
    Germany
    MS-Off Ver
    2007
    Posts
    3

    How to access Userforms created with "add" ? How to add some text inside ?

    Hello, I want to reduce the amount of Userforms in my project.
    Now I read that it is possible to use same Userform multiple times.
    So I tried the following:

    UserForms.Add("Infobox").Show vbModeless
    UserForms.Add("Infobox").Show vbModeless

    Works fine so far. I will get 2 windows with textboxes inside.
    But I don't know how to access the Textbox.
    Ordinary, if I simply would have opened the Userform with "Infobox.Show vbModeless", the following would work to add some text:

    Infobox.TextBox_Infobox.Value = "Halloooooooooooo"

    Why doesn't this work with "Userforms.Add .. " ?
    How and where do I find the names of these new created "windows" ?
    Seems the Window or UserForm-Name isn't "Infobox" anymore ? Or are numbers added somewhere ?
    Don't know .. Maybe someone can help .. would be great .. Thanks very much

  2. #2
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: How to access Userforms created with "add" ? How to add some text inside ?

    You can assign each instance of the userform to a variable and reference it that way.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-20-2021
    Location
    Germany
    MS-Off Ver
    2007
    Posts
    3

    Re: How to access Userforms created with "add" ? How to add some text inside ?

    Great! This works fine. Thanks for your fast support.
    Maybe one question regarding memory consumption and so on .. what is the best way to proceed ?
    Does this method need more or less memory in comparison when I would do several individual userforms ?
    Or is it the same ?
    Or is there a way to clean-up these variables (new infoboxes) once again when doing e.g. an unload ?

  4. #4
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: How to access Userforms created with "add" ? How to add some text inside ?

    You can clean up by setting the variables to nothing
    Please Login or Register  to view this content.
    as a last step.
    The forms themselves will released from memory when they're unloaded.
    I haven't done any tests, but I shouldn't think there'll be a lot of difference in memory consumption between one form loaded twice vs two forms loaded once. However, your overall file size should be smaller with only one userform.

  5. #5
    Registered User
    Join Date
    08-20-2021
    Location
    Germany
    MS-Off Ver
    2007
    Posts
    3

    Post Re: How to access Userforms created with "add" ? How to add some text inside ?

    TOP! Thanks once again. I'm happy :-)
    Couldn't have solved this without your help.

+ 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] Code Clean-Up: Delete "False" worksheet created when "Cancel" is chosen in Input Box
    By Kenny Blackwell in forum Excel Programming / VBA / Macros
    Replies: 25
    Last Post: 08-31-2015, 10:00 AM
  2. CountIF value inside text string "contains" value
    By sbrewitt in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-27-2015, 05:59 PM
  3. Make each cell text inside a Quotation Mark " "
    By Marvin85 in forum Excel General
    Replies: 3
    Last Post: 04-17-2014, 03:11 PM
  4. [SOLVED] round number inside IF-THEN to 4 dp --> if(....,"text "&c4&" text",...)
    By EugalB in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-11-2013, 01:00 AM
  5. Replies: 9
    Last Post: 09-25-2013, 06:26 PM
  6. Can't execute a macro whit text inside procedure header's "()" *Help*
    By Timestamp in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-24-2012, 06:55 AM
  7. "Fall down" a VBA created Pivot Table from data Access
    By Radke in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-06-2005, 07:20 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