"True" is true throughout worksheet

michaelch2934

New Member
Joined
Sep 17, 2018
Messages
33
In one application, I want to determine if a value is true or false. But, once it is set to "True", I want to use this fact throughout the worksheet. Conversely, if this value is "False", I want to likewise use this fact throughout the worksheet.

This is the code I'm using to determine what BackColor is:

Sub BlueTurnButton_Click()
'change blue button color to "on"
BlueTurnButton.BackColor = 16765783
'change red button color to "off"
RedTurnButton.BackColor = 186
'set varable
If BlueTurnButton.BackColor = 16765783 Then
BlueTurn = True
End If
If RedTurnButton.BackColor = 186 Then
RedTurn = False
End If

Now, I want to refer to this True or False nature of BlueTurnButton.BackColor in other applications. If it's True, do thus and so. Inotherwords, if it's Blue's Turn, then this happens. But, if it's Red's Turn, this other thing happens.

Hope I've explained it sufficiently well enough for you to help me with a viable solution. Thanks in advance.
 

Some videos you may like

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,746
Office Version
2010
Platform
Windows
Declare it in a standard code model, above all procedures, just below Option Explicit:

Code:
Dim BlueTurn As Boolean
... and nowhere else.

See VBA Help for Understanding Scope and Visibility
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,746
Office Version
2010
Platform
Windows
I misinformed.

That makes BlueTurn visible throughout the code module in which it appears. To make it visible throughout the project,

Rich (BB code):
Public BlueTurn As Boolean
 

michaelch2934

New Member
Joined
Sep 17, 2018
Messages
33
Okay. I'll try that, as well. Maybe use both. Thanks.
If I wanted to send you the end product (game) how would I do so?
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,746
Office Version
2010
Platform
Windows
Not a gamer, thanks.
 

michaelch2934

New Member
Joined
Sep 17, 2018
Messages
33
Me neither, in the modern sense. My games are in the classic style... Sorry, Connect 4, Checkers, Scrabble... Only re-imagined.
 

Watch MrExcel Video

Forum statistics

Threads
1,099,290
Messages
5,467,779
Members
406,551
Latest member
brennermac

This Week's Hot Topics

Top