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
 

Some videos you may like

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

chicagodiceman

Active Member
Joined
Mar 13, 2004
Messages
371
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]
 

Watch MrExcel Video

Forum statistics

Threads
1,112,211
Messages
5,541,845
Members
410,550
Latest member
ganeshsamant
Top