CF using Toggle Button result

G

gtslabs

I am trying to use CF to hide some cells (actually turning the font
color white).
I made a Control Toggle Button and linked it to cell G8.

The cells I want to hide are say B2...B6
I select that range and goto Conditional Formating

2 Questions:

1) How do I write the "formula is" CF expression testing if G8 is TRUE
or FALSE?
I tried G8=TRUE but that is not working.

2)How do I change the caption of the Toggle Button to show different
text if depressed or not.
So I want it to say SHOW and HIDE
 
J

Jim Rech

=G8=TRUE should work fine as a CF formula.

You'd need a macro to change the button's caption. Double click the button
while you're in design mode and write code like this:

Private Sub ToggleButton1_Click()
If Range("G8").Value = True Then
ToggleButton1.Caption = "Hide"
Else
ToggleButton1.Caption = "Show"
End If
End Sub

You might have to flip the logic I used. Also, better to use a range name
for cell G8 so if you insert a row, etc., the code still works.

--
Jim
|I am trying to use CF to hide some cells (actually turning the font
| color white).
| I made a Control Toggle Button and linked it to cell G8.
|
| The cells I want to hide are say B2...B6
| I select that range and goto Conditional Formating
|
| 2 Questions:
|
| 1) How do I write the "formula is" CF expression testing if G8 is TRUE
| or FALSE?
| I tried G8=TRUE but that is not working.
|
| 2)How do I change the caption of the Toggle Button to show different
| text if depressed or not.
| So I want it to say SHOW and HIDE
 
V

vezerid

On the issue of Formula Is, you need $$ because the formula in CF is
copied identically to cell formulas.

=$G$8=TRUE

HTH
Kostis Vezerides
 
D

David Biddulph

Do you need the =TRUE? Wouldn't =$G$8 do it?
--
David Biddulph


On the issue of Formula Is, you need $$ because the formula in CF is
copied identically to cell formulas.

=$G$8=TRUE

HTH
Kostis Vezerides
 
V

vezerid

Personally I would not put it but I thought that I should maintain the
philosophy the OP used for his formula.

To the OP: Anything numeric and non-zero counts as TRUE in logical
context. Hence, especially since your formula in G8 is logical and
returns TRUE/FALSE, it would be enough to use the simplified formula
as David suggested.

Kostis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top