Code to Show or Hide Text

Fujirich

Active Member
Joined
May 1, 2003
Messages
320
Hi folks, I'm hoping to beg for a little code to help with a project I'm trying to finish.

In B1 on a page called "Setup", I have some text that would normally be red in color. My goal is to have the text color change to the cell's fill color upon opening the workbook with macros enabled. If they are not enabled, the text would remain red, clearly noting that the workbook has not been opened properly with macros enabled.

Any ideas? Any better approaches? Thanks in advance for any help.

Oh - and how does one go about finding the correct color reference so that the right value can be identified and assigned to the changing text color?

Thanks! - Rich
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
I am not able to test this but it would seem that if macros are enabled, the Workbook_Open routine would operate. If they weren't, it wouldn't. Same with the _BeforeClose. You may want to test this a tweak as needed...

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Range("B1").Interior.ColorIndex = 3

End Sub

Private Sub Workbook_Open()
    Range("B1").Interior.ColorIndex = xlNone
End Sub
[/code]
 
Upvote 0

Forum statistics

Threads
1,213,557
Messages
6,114,287
Members
448,562
Latest member
Flashbond

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