i want to make a if the player step into the yellow box the player will thrown back 5 steps back ward

Syaz

New Member
Joined
Jun 14, 2022
Messages
7
Office Version
  1. 2003 or older
Platform
  1. Windows
My problem is everytime i throw dice and step into yellow box, it not step into the yellow box but the step will go to the 5 step backward(G1) and not stop a while in the yellow box(refer to cell G5). This is my Vba.

Sub BoardGame()

Dim dice
Dim x
Dim total

x = 0

dice = Int((6 - 1 + 1) * Rnd + 1)
MsgBox dice

If ActiveCell.Row() <> 5 Or ActiveCell.Column() < 1 Or ActiveCell.Column() > 39 Then
MsgBox "FINISH!"
MsgBox total
Else
x = x + dice
ActiveCell.Offset(0, x).Select
End If


If ActiveCell = Range("G5") Then
ActiveCell.Offset(0, -5).Select
ElseIf ActiveCell = Range("I5") Then
ActiveCell.Offset(0, -7).Select
ElseIf ActiveCell = Range("N5") Then
ActiveCell.Offset(0, 3).Select
ElseIf ActiveCell = Range("U5") Then
ActiveCell.Offset(0, -5).Select
ElseIf ActiveCell = Range("Z5") Then
ActiveCell.Offset(0, 3).Select
ElseIf ActiveCell = Range("AF5") Then
ActiveCell.Offset(0, -7).Select
ElseIf ActiveCell = Range("AM5") Then
ActiveCell.Offset(0, -10).Select
End If


End Sub
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Quite not sure I can understand what to play the game, but it seem you don't want to perform 2 steps within a code run?
stop even before running, and open even after running.
like this:

VBA Code:
Sub BoardGame()
Application.EnableEvens = False
......
<main code>
......
Application.EnableEvens = True
End Sub

If it does not work, try to attach a screenshot/image, before and after.
 
Upvote 0
Quite not sure I can understand what to play the game, but it seem you don't want to perform 2 steps within a code run?
stop even before running, and open even after running.
like this:

VBA Code:
Sub BoardGame()
Application.EnableEvens = False
......
<main code>
......
Application.EnableEvens = True
End Sub

If it does not work, try to attach a screenshot/image, before and after
actually i want to perform 2 steps but it happen one steps .the first step is to step in yellow box then it need to move to next step , 5 box backward.
My code make the step go to through the second step but not the first step that is step in the yellow box.
 
Upvote 0

Forum statistics

Threads
1,215,487
Messages
6,125,085
Members
449,206
Latest member
ralemanygarcia

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top