"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.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
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
 
Upvote 0
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
 
Upvote 0
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?
 
Upvote 0
Me neither, in the modern sense. My games are in the classic style... Sorry, Connect 4, Checkers, Scrabble... Only re-imagined.
 
Upvote 0

Forum statistics

Threads
1,214,947
Messages
6,122,413
Members
449,082
Latest member
tish101

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