+ Reply to Thread
Results 1 to 9 of 9

VBA code - Userform not to close

  1. #1
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    VBA code - Userform not to close

    Hi All

    How do I get my userform to remain open when the following macro runs:

    Please Login or Register  to view this content.

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: VBA code - Userform not to close

    Hi,

    Is your userform in the same workbook as that macro? If it is, the answer is very simple: you can't because you closed the workbook containing the userform.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: VBA code - Userform not to close

    Hi xlnitwit

    Good to hear from you. My UserForm is not in the Workbook that gets opened. I'm not using Unload Me, so am confused. I changed code to the below with a call function and still closes userform...


    Please Login or Register  to view this content.


    Please Login or Register  to view this content.

  4. #4
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: VBA code - Userform not to close

    Is the userform in the workbook that contains the code you are running - i.e. the InvNoGen routine?

    Is there any code run by the workbook you open when it is opened - i.e. does it contain a Workbook_Open event or Auto_Open macro?

  5. #5
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: VBA code - Userform not to close

    Any ideas...Anyone !!!

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: VBA code - Userform not to close

    As far as I can see there's nothing in the code you've posted that would close any userform, unless the userform was in the workbook you were closing.

    Is there any other code, or anything else going on?
    If posting code please use code tags, see here.

  7. #7
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: VBA code - Userform not to close

    Hi Norie

    My thoughts too. The workbook open event, opens up another workbook which hols the following code:

    Sub NoGenerator()
    Range("A1").Value = Range("A1").Value + 1
    Workbooks("No Generator").Close SaveChanges:=True
    End Sub

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: VBA code - Userform not to close

    Have you tried putting something simple like a message box in the QueryClose event of the userform?

    Then, hopefully, when the useform is getting closed by whatever the message box would popup and you could debug from there to investigate what's going on.

  9. #9
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: VBA code - Userform not to close

    Hi Norie

    Pls forgive my ignorance. Have no idea how to do that

+ 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] Userform Close (x) Check condition before close
    By rr1050 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-07-2016, 06:55 AM
  2. [SOLVED] execute code on userform close buton
    By kosherboy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-10-2016, 02:22 PM
  3. Replies: 1
    Last Post: 01-31-2016, 05:54 AM
  4. how to close userform using commndbutton and set automatic close at certain time
    By fatinmunie in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-23-2014, 12:51 PM
  5. Code for save and close Button on Userform
    By cjames2012 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-16-2013, 12:49 AM
  6. Code a Command Button on UserForm not to close upon click - Excel VBA
    By eemiller1997 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 12-14-2012, 02:20 PM
  7. Dissable Close button on Userform or Assign Code
    By RobynC in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-19-2007, 10:07 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