+ Reply to Thread
Results 1 to 16 of 16

Need button to load the next UserForm

Hybrid View

  1. #1
    Registered User
    Join Date
    01-12-2016
    Location
    Blackpool
    MS-Off Ver
    2016
    Posts
    39

    Need button to load the next UserForm

    I'd like a button on a userform to load the next userform from the one I'm on. So what I mean is, I have UserForm1 open and I have a "password" UserForm that appears when a button combination is used, that's UserForm17. I'd like UserForm17 to load the next UserForm from whichever UserForm I'm on.

    Can anyone help?

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

    Re: Need button to load the next UserForm

    To load and display a userform use formname.Show, to unload the current form use Unload Me.

    For example.
    Unload Me
    
    UserForm1.Show
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    01-12-2016
    Location
    Blackpool
    MS-Off Ver
    2016
    Posts
    39

    Re: Need button to load the next UserForm

    Sorry Norie, I don't think I made it clear enough because I'm not quite sure how to word it. I'd like the button combination which loads UserForm17 to move onto the next UserForm on which I load it. So if I loaded UserForm17 up whilst I was on UserForm5, I'd like it to move onto UserForm6.

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

    Re: Need button to load the next UserForm

    The code I posted is just really an example, if you want to load UserForm6 change UserForm1.Show to UserForm6.Show.

    PS What do you mean by 'button combination'?

  5. #5
    Registered User
    Join Date
    01-12-2016
    Location
    Blackpool
    MS-Off Ver
    2016
    Posts
    39

    Re: Need button to load the next UserForm

    It's a macro that basically opens UserForm17 when I press CTRL + SHIFT + J

  6. #6
    Registered User
    Join Date
    01-12-2016
    Location
    Blackpool
    MS-Off Ver
    2016
    Posts
    39

    Re: Need button to load the next UserForm

    I have this code which closes a UserForm:
    Sub CloseForm()
    Dim i As Long, Str As String
    For i = VBA.UserForms.Count - 1 To 0 Step -1
    Str = Str & VBA.UserForms(i).Name & vbNewLine
    Unload VBA.UserForms(i)
    Next i
    End Sub

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

    Re: Need button to load the next UserForm

    That code closes all open userforms.

  8. #8
    Registered User
    Join Date
    01-12-2016
    Location
    Blackpool
    MS-Off Ver
    2016
    Posts
    39

    Re: Need button to load the next UserForm

    Is there anything similar which would open the next UserForm in the row? So open UserForm2 if I used the code on UserForm1 any so on?

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

    Re: Need button to load the next UserForm

    Are the userforms named sequentially? ie UserForm1, UserForm2 etc.

  10. #10
    Registered User
    Join Date
    01-12-2016
    Location
    Blackpool
    MS-Off Ver
    2016
    Posts
    39

    Re: Need button to load the next UserForm

    Yes, and it goes from 1 to 15.

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

    Re: Need button to load the next UserForm

    Perhaps something like this.
    Dim NextForm As String
    
        NextForm = "UserForm" & (Mid(Me.Name, 9) + 1)
        
        Unload Me
        
        UserForms.Add NextForm
    
        UserForms(UserForms.Count - 1).Show

  12. #12
    Registered User
    Join Date
    01-12-2016
    Location
    Blackpool
    MS-Off Ver
    2016
    Posts
    39

    Re: Need button to load the next UserForm

    It just comes back with "Compile error: Invalid use of Me keyword".

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

    Re: Need button to load the next UserForm

    I thought this code was for a button on a userform?

  14. #14
    Registered User
    Join Date
    01-12-2016
    Location
    Blackpool
    MS-Off Ver
    2016
    Posts
    39

    Re: Need button to load the next UserForm

    Here you go.
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    01-12-2016
    Location
    Blackpool
    MS-Off Ver
    2016
    Posts
    39

    Re: Need button to load the next UserForm

    Would you like me to attach the file to take a look?

  16. #16
    Registered User
    Join Date
    01-12-2016
    Location
    Blackpool
    MS-Off Ver
    2016
    Posts
    39

    Re: Need button to load the next UserForm

    Hellooooo?

+ 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. Error trying to import userform into Outlook: Unable to load UserForm.FRX
    By jeffclanders in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-08-2016, 12:36 PM
  2. Replies: 2
    Last Post: 02-02-2016, 10:27 PM
  3. [SOLVED] Userform submit button to load listbox1 and listbox2 selection to same cell
    By wishn4fishn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-28-2013, 03:06 PM
  4. [SOLVED] Linking together an Options Button and a command button inorder to load separate forms
    By emilyloz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-23-2013, 02:10 PM
  5. Userform with Command Button to Load and Execute from a Textfile
    By ThermalTD in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-17-2013, 05:36 AM
  6. how do I get a form button to load up a userform?
    By tomistuck in forum Excel General
    Replies: 1
    Last Post: 02-24-2005, 04:24 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