Results 1 to 4 of 4

Thread: An excel card game

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2005
    Posts
    163

    An excel card game

    I am making a card game as part of my school work using excel vba macro. I am stuck with the stick part when the user presses stick to end his go and let the computer has its.

    I have this but i don't know whats wrong:

    VB Code:
    1. Sub DealerStick3()
    2.  
    3. dealer = Range("F22").Value
    4. setdef = 17
    5.  
    6. If dealer < setdef Then
    7. stick3
    8. Else
    9. ActiveCell.FormulaR1C1 = "=SUM(R[-5]C:R[-1]C)"
    10. End
    11. End If
    12. End Sub
    13.  
    14. Sub stick3()
    15. dealer = Range("F22").Value
    16. setdef = 17
    17.  
    18. dealer3:
    19.     Calculate
    20.     flagcell = Range("H4").Value
    21.     If Range(flagcell).Value = 1 Then
    22.     GoTo dealer3:
    23.     End If
    24.  
    25.     Range("C3:F3").Select
    26.     Selection.Copy
    27.     Range(flagcell).Value = 1
    28.     Range("C19").Select
    29.     Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    30.         :=False, Transpose:=False
    31.    
    32.     Application.CutCopyMode = False
    33. Range("F22").Select
    34. dealer = Range("F22").Value
    35. DealerStick4
    36.     ActiveCell.FormulaR1C1 = "=SUM(R[-5]C:R[-1]C)"
    37. End Sub
    38. Sub DealerStick4()
    39.  
    40. dealer = Range("F22").Value
    41. setdef = 17
    42.  
    43. If dealer < setdef Then
    44. stick4
    45. Else
    46. ActiveCell.FormulaR1C1 = "=SUM(R[-5]C:R[-1]C)"
    47. End
    48. End If
    49. End Sub
    50.  
    51. Sub stick4()
    52. dealer = Range("F22").Value
    53. setdef = 17
    54. dealer4:
    55.     Calculate
    56.     flagcell = Range("H4").Value
    57.     If Range(flagcell).Value = 1 Then
    58.     GoTo dealer4:
    59.     End If
    60.  
    61.     Range("C3:F3").Select
    62.     Selection.Copy
    63.     Range(flagcell).Value = 1
    64.     Range("C20").Select
    65.     Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    66.         :=False, Transpose:=False
    67.    
    68.     Application.CutCopyMode = False
    69. Range("F22").Select
    70. dealer = Range("F22").Value
    71. DealerStick5
    72.     ActiveCell.FormulaR1C1 = "=SUM(R[-5]C:R[-1]C)"
    73. End Sub
    74. Sub DealerStick5()
    75. dealer5:
    76.     Calculate
    77.     flagcell = Range("H4").Value
    78.     If Range(flagcell).Value = 1 Then
    79.     GoTo dealer5:
    80.     End If
    81.    
    82.  
    83.     Range("C3:F3").Select
    84.     Selection.Copy
    85.     Range(flagcell).Value = 1
    86.     Range("C21").Select
    87.     Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    88.         :=False, Transpose:=False
    89.    
    90.     Application.CutCopyMode = False
    91. Range("F22").Select
    92.     ActiveCell.FormulaR1C1 = "=SUM(R[-5]C:R[-1]C)"
    93.     End
    94. End Sub

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Feb 2005
    Posts
    163

    Re: An excel card game

    can't anyone help me, all i need is someon eto check it throgh as i can't find my mistake

  3. #3
    Addicted Member malik641's Avatar
    Join Date
    Sep 2005
    Location
    South Florida :-)
    Posts
    221

    Re: An excel card game

    What errors are you getting?
    Which "stick" part? All your macros have "stick" in them And there are no _Click events...so which macro is it???

    Maybe a posted workbook would help




    If you find any of my posts of good help, please rate it

  4. #4
    Addicted Member malik641's Avatar
    Join Date
    Sep 2005
    Location
    South Florida :-)
    Posts
    221

    Re: An excel card game

    Oh yeah, and I just quickly looked at your code and noticed that your "DealerStick3" and "DealerStick4" have an unnecessary extra "End" in it.

    And you don't have to "Select" anything to do what you want to do. Your code will run more efficient and more quickly that way




    If you find any of my posts of good help, please rate it

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width