Consulting

Results 1 to 5 of 5

Thread: Solved: unload userform before worksheet deactivate

  1. #1

    Solved: unload userform before worksheet deactivate

    I have a userform that I would like to be unloaded before selecting a different worksheet. I know I can just close the userform, but as a backup to forgeting to close the userform, I would like the userform to close automatically. Any suggestions? Thanks.

  2. #2
    VBAX Mentor anandbohra's Avatar
    Joined
    May 2007
    Location
    Mumbai
    Posts
    313
    Location
    by the way when u show a userform how can a user select different worksheet?
    he has to compulsorily close userform for returning to excel


    of something else in your mind type this code in this workbook code

    [VBA]Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
    unload UserForm1
    End Sub
    [/VBA]
    Always Mark your Thread as Solved the moment u got acceptable reply (located under Thread tools)
    Practice this & save time of others in thinking for unsolved thread

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Anandbohra
    If the Userform is opened non-modally, the user can use the spreadsheets etc. as normal. This is done using
    [vba]
    Userform1.Show False
    [/vba]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  4. #4
    VBAX Mentor anandbohra's Avatar
    Joined
    May 2007
    Location
    Mumbai
    Posts
    313
    Location
    Quote Originally Posted by mdmackillop
    Anandbohra
    If the Userform is opened non-modally, the user can use the spreadsheets etc. as normal. This is done using
    [vba]
    Userform1.Show False
    [/vba]
    Thanks mdmackillop
    It something new for me

    btw av8tordude I hope your query is solved as my code unload non-modally opened user form on sheet change
    Always Mark your Thread as Solved the moment u got acceptable reply (located under Thread tools)
    Practice this & save time of others in thinking for unsolved thread

  5. #5
    Thank you both

Posting Permissions

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