Results 1 to 5 of 5

Select Case and UserForm Buttons

Threaded View

  1. #1
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Select Case and UserForm Buttons

    Hi,

    I am stuck with this trying to make this work and any help is appreciated. This code works:

    Private Sub OKButton_Click_Click_1()
        
        If OptionMe Then
            If OptionOne Then
                If OptionOneFile Then
                    Call Import_One_File
                End If
                If OptionAllFiles Then
                    Call Import_One_Folder
                End If
            End If
    
            If OptionTwo Then
                If OptionOneFile Then
                    Call Import_Two_Files
                End If
                If OptionAllFiles Then
                    Call Import_Two_Folders
                End If
            End If
    
            If OptionThree Then
                If OptionOneFile Then
                    Call Import_Three_Files
                End If
                If OptionAllFiles Then
                    Call Import_Three_Folders
                End If
            End If
        End If
    
    End Sub
    but uses a lot of IF statements and the actual code uses a long list of IF statements. So I am trying to simplify things by using Select Case but can't seem to pass the decisions of the three buttons correctly to the macro.

    Here is my Select Case example:

    Private Sub OKButton_Click_Click_2()
    
    ' Couldn't figure out what to put after Select Case so I used "<<>>" as a placemarker    
        Select Case "<<>>"
            Case OptionMe And OptionOne And OptionOneFile
                Call Import_One_File
            Case OptionMe And OptionOne And OptionAllFiles
                Call Import_One_Folder
            Case OptionMe And OptionTwo And OptionOneFile
                Call Import_Two_Files
            Case OptionMe And OptionTwo And OptionAllFiles
                Call Import_Two_Folders
            Case OptionMe And OptionThree And OptionOneFile
                Call Import_Three_Files
            Case OptionMe And OptionThree And OptionAllFiles
                Call Import_Three_Folders
        End Select
        
    End Sub
    Any thoughts?

    abousetta
    Last edited by abousetta; 05-29-2011 at 11:33 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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