Results 1 to 20 of 20

Userform question about IF w/outputs on multiple lines

Threaded View

  1. #1
    Forum Contributor
    Join Date
    07-27-2009
    Location
    montreal, canada
    MS-Off Ver
    Excel 2003
    Posts
    230

    Userform question about IF w/outputs on multiple lines

    I'm trying to get a form going for our tennis rankings.

    Check the file, my code for checking if a player played and keep his score, and opponants score is long and flawed:

    Private Sub CommandButton1_Click()
    
    Dim emptyRow As Long
    
    Sheets("Résultats").Activate
    emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
    
    If Pointsform.Boxandre1.Value = True Then
        Cells(emptyRow, 1).Value = Calendar1.Value
        Cells(emptyRow, 2).Value = "André"
        Cells(emptyRow, 3).Value = Score1.Value
        Cells(emptyRow, 4).Value = Score2.Value
        
        Else
            
        End If
    
    If Pointsform.boxsimon1.Value = True Then
        Cells(emptyRow, 1).Value = Calendar1.Value
        Cells(emptyRow, 2).Value = "Simon"
        Cells(emptyRow, 3).Value = Score1.Value
        Cells(emptyRow, 4).Value = Score2.Value
        
        Else
            
        End If
    
    
    If Pointsform.boxpascal1.Value = True Then
        Cells(emptyRow, 1).Value = Calendar1.Value
        Cells(emptyRow, 2).Value = "Pascal"
        Cells(emptyRow, 3).Value = Score1.Value
        Cells(emptyRow, 4).Value = Score2.Value
        
        Else
            
        End If
    
    If Pointsform.boxsylvain1.Value = True Then
        Cells(emptyRow, 1).Value = Calendar1.Value
        Cells(emptyRow, 2).Value = "Sylvain"
        Cells(emptyRow, 3).Value = Score1.Value
        Cells(emptyRow, 4).Value = Score2.Value
        
        Else
            
        End If
    
    If Pointsform.boxthierry1.Value = True Then
        Cells(emptyRow, 1).Value = Calendar1.Value
        Cells(emptyRow, 2).Value = "Thierry"
        Cells(emptyRow, 3).Value = Score1.Value
        Cells(emptyRow, 4).Value = Score2.Value
        
        Else
            
        End If
        
    If Pointsform.boxyve1.Value = True Then
        Cells(emptyRow, 1).Value = Calendar1.Value
        Cells(emptyRow, 2).Value = "Yvé"
        Cells(emptyRow, 3).Value = Score1.Value
        Cells(emptyRow, 4).Value = Score2.Value
        
        Else
            
        End If
    
    If Pointsform.Boxandre2.Value = True Then
        Cells(emptyRow, 1).Value = Calendar1.Value
        Cells(emptyRow, 2).Value = "André"
        Cells(emptyRow, 3).Value = Score2.Value
        Cells(emptyRow, 4).Value = Score1.Value
        
        Else
            
        End If
    
    
    If Pointsform.boxsimon2.Value = True Then
        Cells(emptyRow, 1).Value = Calendar1.Value
        Cells(emptyRow, 2).Value = "Simon"
        Cells(emptyRow, 3).Value = Score2.Value
        Cells(emptyRow, 4).Value = Score1.Value
        
        Else
            
        End If
    
    If Pointsform.boxpascal2.Value = True Then
        Cells(emptyRow, 1).Value = Calendar1.Value
        Cells(emptyRow, 2).Value = "Pascal"
        Cells(emptyRow, 3).Value = Score2.Value
        Cells(emptyRow, 4).Value = Score1.Value
        
        Else
            
        End If
    
    If Pointsform.boxsylvain2.Value = True Then
        Cells(emptyRow, 1).Value = Calendar1.Value
        Cells(emptyRow, 2).Value = "Sylvain"
        Cells(emptyRow, 3).Value = Score2.Value
        Cells(emptyRow, 4).Value = Score1.Value
        
        Else
            
        End If
        
    If Pointsform.boxthierry2.Value = True Then
        Cells(emptyRow, 1).Value = Calendar1.Value
        Cells(emptyRow, 2).Value = "Thierry"
        Cells(emptyRow, 3).Value = Score2.Value
        Cells(emptyRow, 4).Value = Score1.Value
        
        Else
            
        End If
    
    If Pointsform.boxyve2.Value = True Then
        Cells(emptyRow, 1).Value = Calendar1.Value
        Cells(emptyRow, 2).Value = "Yvé"
        Cells(emptyRow, 3).Value = Score2.Value
        Cells(emptyRow, 4).Value = Score1.Value
        
        Else
            
        End If
    
    Score1.Value = ""
    Score2.Value = ""
    
    Boxandre1.Value = False
    boxsimon1.Value = False
    boxpascal1.Value = False
    boxsylvain1.Value = False
    boxthierry1.Value = False
    boxyve1.Value = False
    Boxandre2.Value = False
    boxsimon2.Value = False
    boxpascal2.Value = False
    boxsylvain2.Value = False
    boxthierry2.Value = False
    boxyve2.Value = False
    
    Unload Me
    
    
    End Sub

    Only the last guy ticked gets his name on the "Résultats" sheets.
    can someone help me simplify?
    Attached Files Attached Files
    Last edited by Sibrulotte; 03-23-2012 at 11:45 AM.

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