Consulting

Results 1 to 7 of 7

Thread: UserForm Running - While Jumping to Application GoTo Statement - Unload

  1. #1
    VBAX Mentor
    Joined
    Feb 2016
    Location
    I have lived in many places, I love to Travel
    Posts
    413
    Location

    UserForm Running - While Jumping to Application GoTo Statement - Unload

    folks,

    good evening,

    I thought i would work a bit on my userform its been stuck for a while.

    I cant figure out what the problem is.

    I used application go to to go to the location of the macro

    But the userform is still running and wont let me edit in the module.

    I just want to go to the module - Yes it does that , but the userform is still running so i cant do anything - unless i close the userform

    if i close the userform i lose my location that i jumped to

    Private Sub CommandButton1_Click()
    
    
    'Go to the macro place in the module macros
      
        With Application
            .Goto ListBox1.Column(1)
        End With
        Unload Me     ' <<<  this wont let me go to the module
      
    End Sub
    what can i use to stop the userform running while i jump to the module

    its not very clear what i mean but you can see form the userform

    I have attached the offending culprit here

    thank you for your advice
    Attached Files Attached Files
    Cheers for your help

    dj

    'Extreme VBA Newbie in progress - one step at a time - like a tortoise's pace'


  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    Try this in the user form code


    Private Sub CommandButton1_Click()
        
        sMacroToRun = ListBox1.Column(1)
        
        Me.Hide
        
        With Application
            .Run sMacroToRun
        End With
        
        Unload Me
        
    End Sub
    with this in the Macros module

    Option Explicit
    
    Public sMacroToRun As String
     
      
    Sub UF_Show()
    UFListBox.Show
    End Sub
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    VBAX Mentor
    Joined
    Feb 2016
    Location
    I have lived in many places, I love to Travel
    Posts
    413
    Location
    Hello Paul,

    good weekend

    I forgot about the hide.me

    Becuase i was using unload me.

    The reason i was using application goto is so that I can also navigate to the Module Macros and go to that sub procedure - so i can inspect it



    is there a way of opening the Module to that Sub.

    For example how would i go to

    myTestMacro23 in the code module

    Normally i use application GOTO and it jumps there, but with the userform - I dont know it doesnt like to do that well it does but it still runs

    i hope i made some modicum of sence
    Cheers for your help

    dj

    'Extreme VBA Newbie in progress - one step at a time - like a tortoise's pace'


  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    Not sure about

    so that I can also navigate to the Module Macros and go to that sub procedure - so i can inspect it
    I usually use F9 to put a breakpoint on the appropriate line so that the macro stops there and then I can single step through it

    Capture.JPG
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  5. #5
    VBAX Mentor
    Joined
    Feb 2016
    Location
    I have lived in many places, I love to Travel
    Posts
    413
    Location
    Hello Paul,

    Actually I think it worked

    it went to the location and the userform stopped runnning


    Private Sub CommandButton1_Click()
        
        sMacroToRun = ListBox1.Column(1)
        
        Me.Hide
    
    
        With Application
            .Goto ListBox1.Column(1)
        End With
        'Unload Me
      
    End Sub
    No unload me at the end, and it wasnt running as before.

    Let me fiddle in case i run into somehting again
    Cheers for your help

    dj

    'Extreme VBA Newbie in progress - one step at a time - like a tortoise's pace'


  6. #6
    VBAX Mentor
    Joined
    Feb 2016
    Location
    I have lived in many places, I love to Travel
    Posts
    413
    Location
    This did perplex me into a corner - the userform previously kept running with no instructions from me to do so what so ever,
    i thought code was meant to be very explicit with the instructions
    well it always fails to follow mine even when i tell it so

    Well Im making some progress on my userform project

    I'll be finished in another million years me thinks..

    but its all learning good fun untill I break the array and i cant find my missing declaration

    but..i'll keep on keep on...

    thanks Paul

    good weekend all
    Cheers for your help

    dj

    'Extreme VBA Newbie in progress - one step at a time - like a tortoise's pace'


  7. #7
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    OK, but try putting a breakpoint on the Run line (F9) and use F8 single step instead of the GoTo instead
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

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