Reputation: 1483
I am trying to select a different case for each different string combination that can be passed in. In this case I'm using abbreviations for baseball positions.
To make it easier I have added a String value called "Position" to be what is compared.
I'm currently getting the error:
Compile Error: Case without Select Case
I assume it's some kind of formatting error, but I haven't been able to find anything online that fixes it.
Position = "test"
Select Case Position
Case "C"
If C.DollarPerWar < Cells(i, 8).Value Then
Set C = AssignPlayer(C, CurrentPlayer)
Case "1B"
If B1.DollarPerWar < Cells(i, 8).Value Then
Set B1 = AssignPlayer(B1, CurrentPlayer)
Case "2B"
If B2.DollarPerWar < Cells(i, 8).Value Then
Set B2 = AssignPlayer(B2, CurrentPlayer)
Case "3B"
If B3.DollarPerWar < Cells(i, 8).Value Then
Set B3 = AssignPlayer(B3, CurrentPlayer)
Case "SS"
If SS.DollarPerWar < Cells(i, 8).Value Then
Set SS = AssignPlayer(SS, CurrentPlayer)
Case "LF"
If LF.DollarPerWar < Cells(i, 8).Value Then
Set LF = AssignPlayer(LF, CurrentPlayer)
Case "CF"
If CF.DollarPerWar < Cells(i, 8).Value Then
Set CF = AssignPlayer(CF, CurrentPlayer)
Case "RF"
If RF.DollarPerWar < Cells(i, 8).Value Then
Set RF = AssignPlayer(RF, CurrentPlayer)
End Select
Any help would be appreciated!
Upvotes: 1
Views: 469
Reputation: 9932
Kill your new line in your if-statement. They should be a single line as shown below:
If RF.DollarPerWar < Cells(i, 8).Value Then Set RF = AssignPlayer(RF, CurrentPlayer)
Upvotes: 2