VBA Arguments not optional

  • 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 as 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.








    Any suggestions?

  • Re: VBA Arguments not optional


    Sure. Please note I am just a beginner.


  • Re: VBA Arguments not optional


    No problem :)


    FindWinner Expects 2 arguments, p1stat and p2stat. You aren't passing either of these, so the code errors, it should look something like:

    Code
    For count = 0 To 15             
                  If ActiveCell.Offset(count, 0) = "" And ActiveCell.Offset(count - 1, 0) <> "" Then ActiveCell.Offset(count, 0) = FindWinner(someStat, SomeOtherStaT)
            Next count
  • Re: VBA Arguments not optional


    Thank you very much!


    Quote from Kyle123;633821

    No problem :)


    FindWinner Expects 2 arguments, p1stat and p2stat. You aren't passing either of these, so the code errors, it should look something like:

    Code
    For count = 0 To 15             
                  If ActiveCell.Offset(count, 0) = "" And ActiveCell.Offset(count - 1, 0) <> "" Then ActiveCell.Offset(count, 0) = FindWinner(someStat, SomeOtherStaT)
            Next count

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!