+ Reply to Thread
Results 1 to 12 of 12

Load & Unload UserForm when changing workbooks

  1. #1
    Registered User
    Join Date
    01-25-2013
    Location
    Cyprus
    MS-Off Ver
    Excel 2003
    Posts
    11

    Load & Unload UserForm when changing workbooks

    Hello,

    I have two workbooks. Test1.xls and Text2.xls
    The Test1 workbook has 3 worksheets(sheet1, sheet2 and sheet3)

    I have 2 userforms in workbook Test1.

    On Workbook open event, I use this codes in “ThisWorkbook”:

    Please Login or Register  to view this content.
    and

    Please Login or Register  to view this content.
    On Userform1 I have a button that forwards to Sheet2 that opens the Userform2 using this code:

    Please Login or Register  to view this content.
    When I choose or open the Test2 file, I hide or Unload the UserForm2 ( Using the Private Sub Workbook_Deactivate() event which it is working)

    Now, the problem is:
    when I will go back to Test1 file, I want to show the UserForm2 again in vbModeless.
    How can I do this?

    Does anybody can help?
    Thank you

    Moderator Note:

    Pls use code tags around your code next time as per forum rules.
    Last edited by Fotis1991; 11-15-2013 at 06:41 AM.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Load & Unload UserForm when changing workbooks

    Hi, OneSurya,

    sounds to me as if you may use the Workbook_Activate-event in ThisWorkbook of Test1 file to do what you want.

    Ciao,
    Holger
    Last edited by HaHoBe; 11-15-2013 at 06:51 AM. Reason: typos
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    01-25-2013
    Location
    Cyprus
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Load & Unload UserForm when changing workbooks

    Thanks for the reply,

    I've tried it but does not work.

    Thanks

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Load & Unload UserForm when changing workbooks

    Hi, OneSurya,

    if you place this code in ThisWorkbook of Test1:
    Please Login or Register  to view this content.
    what is it that´s not working or what else are you expecting the code to do, quite frankly: I don´t get the use of
    Please Login or Register  to view this content.
    Ciao,
    Holger

  5. #5
    Registered User
    Join Date
    01-25-2013
    Location
    Cyprus
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Load & Unload UserForm when changing workbooks

    Thanks again for the reply.
    It is working!
    If I want to go to sheet3 and use a third userform, how am I will write the code in Private Sub Workbook_Activate()
    in ThisWorkbook in the file Text1?


    (AppActivate Application.Caption) I write this code after the vbmodeless to activate or get focus at the current cell.


    Thanks a lot "Holger"

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Load & Unload UserForm when changing workbooks

    Hi, OneSurya,

    Please Login or Register  to view this content.
    Ciao,
    Holger

  7. #7
    Registered User
    Join Date
    01-25-2013
    Location
    Cyprus
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Load & Unload UserForm when changing workbooks

    Hello Holger,

    Thanks for the reply.

    Using this code below, both userforms appear the same time when I activate sheet2 or sheet3.

    Please Login or Register  to view this content.
    When I am in sheet2 and I choose or open the Test2 file, I hide or Unload the UserForm2 ( Using the Private Sub Workbook_Deactivate() event which it is working)

    Now, the problem again is:
    when I will go back to Test1 file sheet2, I want to show the UserForm2 again in vbModeless.

    How can I do this?

    Do you suggest any other solution?

    Thank you,
    Andreas

    P.S. What are the code-tags? I used these <Code>
    Last edited by OneSurya; 11-18-2013 at 08:52 AM.

  8. #8
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Load & Unload UserForm when changing workbooks

    Hi, Andreas,

    Fotis1991 asked you to apply code-tags in your opening post (which Fotis put in there for you) - I´m afraid you would need to add them to your last post.

    If done you would need to make clear which sheet you want to be the active one (and which userform should be shown). From the code you posted both sheets will be activated and each of the UserForms be shown.

    Again: please wrap your procedure with code-tags to allow us to reply to your question.

    Holger

  9. #9
    Registered User
    Join Date
    01-25-2013
    Location
    Cyprus
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Load & Unload UserForm when changing workbooks

    What are the code-tags? I used these
    [Code]
    code goes here
    [\Code]

    Is it ok?
    Last edited by OneSurya; 11-18-2013 at 08:54 AM.

  10. #10
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Load & Unload UserForm when changing workbooks

    Hi, Andreas,

    normally you would use [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code]. Or you could edit the post and mark the code and hit #.

    You would need to use a back-slash opposed to a slash to end the tags.

    Please Login or Register  to view this content.
    Ciao,
    Holger

  11. #11
    Registered User
    Join Date
    01-25-2013
    Location
    Cyprus
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Load & Unload UserForm when changing workbooks

    I edited the code and the post.
    You can take a look at it.

    Thanks
    Andreas
    Last edited by OneSurya; 11-25-2013 at 04:34 AM.

  12. #12
    Registered User
    Join Date
    01-25-2013
    Location
    Cyprus
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Load & Unload UserForm when changing workbooks

    Hello Holger,

    Thanks for the reply.

    Using this code below in Thisworkbook, both userforms appear the same time when I activate sheet2 or sheet3.

    Please Login or Register  to view this content.
    When I am in sheet2 and I choose or open the Test2 file, I hide or Unload the UserForm2 ( Using the Private Sub Workbook_Deactivate() event which it is working)

    Now, the problem again is:
    when I will go back to Test1 file sheet2, I want to show the UserForm2 again in vbModeless.
    ( More details are in the sample file (Test1.xls))

    How can I do this?

    Do you suggest any other solution?
    I enclose a sample file Test1.xls
    Test1.xls

    Thank you,
    Andreas

+ 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] load/unload userform
    By Fred in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-21-2016, 04:19 AM
  2. Load, unload and reset the listbox
    By ABSTRAKTUS in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-29-2012, 03:01 PM
  3. Form Load/Unload Display Issues
    By yellephant in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-02-2007, 09:34 AM
  4. Userform Question (Load/Unload/Show/Hide)
    By RPIJG in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-02-2005, 06:20 PM
  5. Can't load or unload object
    By jase in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-09-2005, 04:05 PM

Tags for this Thread

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