Button or key to conditionally change text foreground color?
Kurt
Add this code into the VBE (press ALT + F11) then <Insert<Module and cut
and paste the following code: into a module (most likely module 1):
Sub RedButton()
Dim rng As Range
Dim cl As Range
Set rng = Range("A1:I9")
For Each cl In rng
If IsEmpty(cl) Then
cl.Font.ColorIndex = 3
Else
cl.Font.ColorIndex = 0
End If
Next cl
End Sub
Now go back to worksheet and select <View<Toolbars<Forms and then click
the 'Button' icon and drag onto yor worksheet and 'assign' the macro
'RedButton'. Now right-click the button and <Edit Text and give the button a
name.
Each time you now press the button the empty cells in range A1:I9 will have
a red foreground.
Hope this helps
Alex
"Kurt Swanson" wrote:
I would like to find some quick method (some sort of visible button or
hotkey) for the user of a worksheet to change the text foreground
color for certain cells in a block of cells (A1:I9) to some specific color
if and only if the cell is blank. I.e. when the user hits this "red"
key/button, every empty cell in A1:I9 gets a new foreground text
color--red. Nothing would be immediately apparent, as these are empty
cells, but as soon as the user starts entering values into these
cells, the data would be shown in red... a "make all new data red"
button/key.
Is this possible? How?
--
© 2005 Kurt Swanson AB
|