+ Reply to Thread
Results 1 to 3 of 3

Userform_initialize, select Multipage tab based on which previous userform button pressed?

Hybrid View

  1. #1
    Registered User
    Join Date
    09-04-2013
    Location
    york
    MS-Off Ver
    Excel 2013
    Posts
    8

    Userform_initialize, select Multipage tab based on which previous userform button pressed?

    Hi All,

    I am fairly new to userform's so any help would be greatly appreciated.

    Scenario - I have two userform's in excel 2013, when a button ("CommandButton3" or "CommandButton5") on the first userform (MasterPage1) is pressed it opens a second userform (Layer12) which contains a multipage. I want to select a certain tab, based on which button was pressed on the previous userform.

    my code:
    Private Sub UserForm_Initialize()
    
    Select Case Application.Caller
    Case "CommandButton3"
    '1st tab
    Me.MultiPage1.Value = 0
    '3rd tab
    Case "CommandButton5"
    Me.MultiPage1.Value = 3
    End Select
    
    End Sub
    I have also tried:

    Private Sub UserForm_Initialize()
    
    If MasterPage1.CommandButton3.Value = True Then
        Me.MultiPage1.Value = 0
    ElseIf MasterPage1.CommandButton5.Value = True Then
        Me.MultiPage1.Value = 3
    
    End If
    
    End Sub
    Neither work.
    Any suggestions as to where I am going wrong would be appreciated.

    Many Thanks,
    Jonathan
    Last edited by arlu1201; 09-06-2013 at 01:57 AM.

  2. #2
    Registered User
    Join Date
    09-04-2013
    Location
    york
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: Userform_initialize, select Multipage tab based on which previous userform button pres

    OK, so I have found a workaround. May not be the "correct way of doing it", but it works

    I do this by naming the Tag in the subroutine:
    Private Sub CommandButton3_Click()
    
        Load Layer12
        Layer12.Tag = "Raise Purchase Order"
        Layer12.Show
    
    End Sub
    then referencing the tag using:

    Private Sub UserForm_Activate()
        If Me.Tag = "edit specifications" Then Me.MultiPage1.Value = 3
        If Me.Tag = "Raise Purchase Order" Then Me.MultiPage1.Value = 0
    
    End Sub
    Sorted
    Last edited by arlu1201; 09-06-2013 at 01:57 AM.

  3. #3
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Userform_initialize, select Multipage tab based on which previous userform button pres

    Jonathan,

    Welcome to the forum and thanks for posting the solution.

    I have added code tags to your posts. As per forum rule 3, you need to use them whenever you put any code in your post. Please add them in future. In order to put code tags, either type [CODE] before your code and [/CODE] at the end of it, OR you can highlight your code and click the # icon at the top of your post window.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ 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. Back button on a multipage userform
    By qball in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-13-2021, 05:02 AM
  2. Select specific MultiPage in a UserForm with other pages grayed out
    By onmyway in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-04-2012, 02:56 PM
  3. Error when previous button clicked when on First Multipage
    By jwala in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-04-2010, 12:44 AM
  4. [SOLVED] select [a1]cell when hotkey(ctrl+q) pressed, after userform load
    By x taol in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-27-2006, 06:10 PM
  5. [SOLVED] Userform, multipage, select a tab
    By Jos Vens in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-28-2005, 01:06 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