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

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

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]
 

Forum statistics

Threads
1,141,429
Messages
5,706,406
Members
421,447
Latest member
arthuro2021

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
Top