Arcticwarrio
Active Member
- Joined
- Dec 6, 2005
- Messages
- 439
Hi Everyone,
just because i wanted to, i want to try and make a lights out game in excel
i cant figure out how to reset the game without calling a loop or something the part in red
also some kind of pattern generator to start off with (not looked at this yet)
if you want to make it resize columns A to E and rows 1 to 5 as 80 pixels wide and grid border A1:E5
cell G2 says RESET and the score is displayed in G4
p.s. the protect sheet is to stop you from cheating
just because i wanted to, i want to try and make a lights out game in excel
i cant figure out how to reset the game without calling a loop or something the part in red
also some kind of pattern generator to start off with (not looked at this yet)
if you want to make it resize columns A to E and rows 1 to 5 as 80 pixels wide and grid border A1:E5
cell G2 says RESET and the score is displayed in G4
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count <> 1 Then Exit Sub
[COLOR=Red]If Target = "G2" Then Range("A1:E5").Interior.ColorIndex = xlNone[/COLOR]
If Target.Column > 5 Or Target.Row > 5 Then GoTo ROW5
ActiveSheet.Unprotect
If Target.Interior.ColorIndex = xlNone Then Target.Interior.ColorIndex = 8 Else Target.Interior.ColorIndex = xlNone
If Target.Row = 5 Then GoTo ROW1
If Target.Offset(1, 0).Interior.ColorIndex = 8 Then Target.Offset(1, 0).Interior.ColorIndex = xlNone Else Target.Offset(1, 0).Interior.ColorIndex = 8
ROW1:
If Target.Column = 5 Then GoTo ROW2
If Target.Offset(0, 1).Interior.ColorIndex = 8 Then Target.Offset(0, 1).Interior.ColorIndex = xlNone Else Target.Offset(0, 1).Interior.ColorIndex = 8
ROW2:
If Target.Row = 1 Then GoTo ROW3
If Target.Offset(-1, 0).Interior.ColorIndex = 8 Then Target.Offset(-1, 0).Interior.ColorIndex = xlNone Else Target.Offset(-1, 0).Interior.ColorIndex = 8
ROW3:
If Target.Column = 1 Then GoTo ROW4
If Target.Offset(0, -1).Interior.ColorIndex = 8 Then Target.Offset(0, -1).Interior.ColorIndex = xlNone Else Target.Offset(0, -1).Interior.ColorIndex = 8
ROW4:
Range("G4").Value = Range("G4").Value + 1
ROW5:
'ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Application.EnableEvents = False
Range("G1").Select
Application.EnableEvents = True
End Sub
p.s. the protect sheet is to stop you from cheating
Last edited: