0

Below I have two subs, once RearrangeDecks is run, it will call moveToEnd(p1stat,p2stat). I get p1stat and p2stat from a different sub used earlier. However when I run it, it gives me back an error saying "Arguments not optional" as well ass highlighting the first offset word in the sub "MoveToEnd."

In in essence, I have 2 lists of cards. What im trying to code is if P1stat is bigger, then I want the top card of the first stack (Range D3 from D3:D18) to be brought to the bottom of the stack and then the top card of the second stack to be brought to the bottom of the first (so , if p1Stat is bigger, then I want F3 to go from F3:F18 to the bottom of D3:D18) If p2Stat is bigger, then I want the top of F3:F18 to go to the bottom as well as the top card or B3 to go to the bottom of the range of F3:F18.

Public Sub RearrangeDecks()
    'Call MoveToEnd(currentWinner)
    MoveToEnd p1Stat, p2Stat
    Call ShiftUp
    Worksheets("Battle").Activate
End Sub

Sub MoveToEnd(ByVal p1Stat As Integer, ByVal p2Stat As Integer)

    Worksheets("Card Assignments").Activate

    Dim count As Integer

If p1Stat > p2Stat Then
    Range("D3").Activate
    For count = 0 To 15
        If ActiveCell.Offset(count, 0) = "" And ActiveCell.Offset(count - 1, 0) <> "" Then ActiveCell.Offset(count, 0) = FindWinner
    Next count
    For count = 0 To 15
        If ActiveCell.Offset(count, 0) = "" And ActiveCell.Offset(count - 1, 0) <> "" Then ActiveCell.Offset(count, 0) = Range("F3").Value
    Next count
ElseIf p2Stat > p1Stat Then
    Range("F3").Activate
    For count = 0 To 15
        If ActiveCell.Offset(count, 0) = "" And ActiveCell.Offset(count - 1, 0) <> "" Then ActiveCell.Offset(count, 0) = FindWinner
    Next count
    For count = 0 To 15
        If ActiveCell.Offset(count, 0) = "" And ActiveCell.Offset(count - 1, 0) <> "" Then ActiveCell.Offset(count, 0) = Range("D3").Value
    Next count
ElseIf p1Stat = p2Stat Then
        Range("D3").Activate
    For count = 0 To 15
        If ActiveCell.Offset(count, 0) = "" And ActiveCell.Offset(count - 1, 0) <> "" Then ActiveCell.Offset(count, 0) = Range("D3").Value
    Next count
    Range("F3").Activate
    For count = 0 To 15
        If ActiveCell.Offset(count, 0) = "" And ActiveCell.Offset(count - 1, 0) <> "" Then ActiveCell.Offset(count, 0) = Range("F3").Value
    Next count

    End If



End Sub

Any suggestions?

2
Contributors
1
Reply
3
Views
5 Years
Discussion Span
Last Post by AndreRet
0

"Arguments not optional" -

Not exactly sure what was set previously...

This error will normally return true when you have ste the values differently, i.e you have set a value between 1 - 10, you now want the sub to return say a string "hello". the error will tell you that the argument of hello is not optional, needs to be an integer...

This is what I could gather from the above...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.