I have a User Form where a user can select multiple values where they want to enter a person's name onto the spreadsheet. The macro should be looping through all 4 potential selections and placing the name in the "D" Column based upon conditions set in columns "O" and "P". However, my loop is stopping after it enters the first person's name. I believe it's because once the first "True" statement is found, it stops evaluating the rest of the statement. I've searched on the internet, but I'm having trouble figuring out a better way to complete this. Any help would be greatly appreciated, thanks!
Private Sub btnAddToScoreSheet_Click() Dim RelayNumber1 As Long, RelayNumber2, RelayNumber3, RelayNumber4 Dim PostNumber1 As Long, PostNumber2, PostNumber3, PostNumber4 Dim SquadNumber1 As Long, SquadNumber2, SquadNumber3, SquadNumber4 Dim PlayerName As String Dim WS As Worksheet Dim LastRow As Long SquadNumber1 = Me.txtSquad1.Value SquadNumber2 = Me.txtSquad2.Value SquadNumber3 = Me.txtSquad3.Value SquadNumber4 = Me.txtSquad4.Value RelayNumber1 = Me.txtRelay1.Value RelayNumber2 = Me.txtRelay2.Value RelayNumber3 = Me.txtRelay3.Value RelayNumber4 = Me.txtRelay4.Value PostNumber1 = Me.txtPost1.Value PostNumber2 = Me.txtPost2.Value PostNumber3 = Me.txtPost3.Value PostNumber4 = Me.txtPost4.Value PlayerName = Me.txtPlayerName.Value Application.ScreenUpdating = False Set WS = ActiveWorkbook.Worksheets("Score Sheet") LastRow = WS.Cells(Rows.Count, 1).End(xlUp).Row For r = 2 To LastRow If WS.Cells(r, 15) = SquadNumber1 And WS.Cells(r, 16) = PostNumber1 Then WS.Cells(r, 4).Value = PlayerName Me.txtSquad1.Value = "" Me.txtPost1.Value = "" Me.txtRelay1.Value = "" ElseIf WS.Cells(r, 15) = SquadNumber2 And WS.Cells(r, 16) = PostNumber2 Then WS.Cells(r, 4).Value = PlayerName Me.txtSquad2.Value = "" Me.txtPost2.Value = "" Me.txtRelay2.Value = "" ElseIf WS.Cells(r, 15) = SquadNumber3 And WS.Cells(r, 16) = PostNumber3 Then WS.Cells(r, 4).Value = PlayerName Me.txtSquad3.Value = "" Me.txtPost3.Value = "" Me.txtRelay3.Value = "" ElseIf WS.Cells(r, 15) = SquadNumber4 And WS.Cells(r, 16) = PostNumber4 Then WS.Cells(r, 4).Value = PlayerName Me.txtSquad4.Value = "" Me.txtPost4.Value = "" Me.txtRelay4.Value = "" End If Next r MsgBox "Added all squads to sheet" Application.ScreenUpdating = True Unload Me End Sub