C
conwrath
Guest
I am having trouble making a reset button in visual basic editor ms excel for my maze game projecT
Option Explicit
Public OldPosition As Range
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If OldPosition Is Nothing Then Set OldPosition = Target.Parent.Range("AF9") 'adjust AF9 to your start position
If Target.Interior.Color = vbBlack Or Target.Row = 1 Or Target.Column = 1 Or Intersect(Target, OldPosition.Offset(-1, -1).Resize(3, 3)) Is Nothing Then
Application.EnableEvents = False
OldPosition.Select
Application.EnableEvents = True
Else
OldPosition.Interior.Pattern = xlNone
Set OldPosition = Target
OldPosition.Interior.Color = vbRed
End If
If Not Intersect(Target, Target.Parent.Range("V50")) Is Nothing Then
MsgBox "you finished"
End If
End Sub
This is the code i do not know what to add to make the reset button go back to AF9 the starting cell in my maze game
Continue reading...
Option Explicit
Public OldPosition As Range
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If OldPosition Is Nothing Then Set OldPosition = Target.Parent.Range("AF9") 'adjust AF9 to your start position
If Target.Interior.Color = vbBlack Or Target.Row = 1 Or Target.Column = 1 Or Intersect(Target, OldPosition.Offset(-1, -1).Resize(3, 3)) Is Nothing Then
Application.EnableEvents = False
OldPosition.Select
Application.EnableEvents = True
Else
OldPosition.Interior.Pattern = xlNone
Set OldPosition = Target
OldPosition.Interior.Color = vbRed
End If
If Not Intersect(Target, Target.Parent.Range("V50")) Is Nothing Then
MsgBox "you finished"
End If
End Sub
This is the code i do not know what to add to make the reset button go back to AF9 the starting cell in my maze game
Continue reading...