Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 82
Default Option Button code not working

I am trying to use this code to hide/unhide text and background color. For
some reason it is not working. I want to have two option buttons and if 1 is
not checked the font and background should disappear. It's not happening when
I click on Option Button 2?

Private Sub OptionButton1_Click()

If OptionButton1.Value = True Then
Me.Range("Y27:AA27").Font.Color = RGB(0, 0, 0)
Else
Me.Range("Y27:AA27").Font.Color = RGB(255, 255, 255)
End If

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Option Button code not working

Sara,

You need to put it in the change event because it can never become FALSE by
clicking it. Try this variation

Private Sub OptionButton1_Change()
If OptionButton1.Value = True Then
Range("Y27:AA27").Font.ColorIndex = 2
Else
Range("Y27:AA27").Font.ColorIndex = 0
End If
End Sub

Mike

"Sara" wrote:

I am trying to use this code to hide/unhide text and background color. For
some reason it is not working. I want to have two option buttons and if 1 is
not checked the font and background should disappear. It's not happening when
I click on Option Button 2?

Private Sub OptionButton1_Click()

If OptionButton1.Value = True Then
Me.Range("Y27:AA27").Font.Color = RGB(0, 0, 0)
Else
Me.Range("Y27:AA27").Font.Color = RGB(255, 255, 255)
End If

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,420
Default Option Button code not working

That vent won't kick in if the second is clicked, so you need similar code
in its click event.

--
__________________________________
HTH

Bob

"Sara" wrote in message
...
I am trying to use this code to hide/unhide text and background color. For
some reason it is not working. I want to have two option buttons and if 1
is
not checked the font and background should disappear. It's not happening
when
I click on Option Button 2?

Private Sub OptionButton1_Click()

If OptionButton1.Value = True Then
Me.Range("Y27:AA27").Font.Color = RGB(0, 0, 0)
Else
Me.Range("Y27:AA27").Font.Color = RGB(255, 255, 255)
End If

End Sub



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 82
Default Option Button code not working

Thank you so much Mike. That worked.

"Mike H" wrote:

Sara,

You need to put it in the change event because it can never become FALSE by
clicking it. Try this variation

Private Sub OptionButton1_Change()
If OptionButton1.Value = True Then
Range("Y27:AA27").Font.ColorIndex = 2
Else
Range("Y27:AA27").Font.ColorIndex = 0
End If
End Sub

Mike

"Sara" wrote:

I am trying to use this code to hide/unhide text and background color. For
some reason it is not working. I want to have two option buttons and if 1 is
not checked the font and background should disappear. It's not happening when
I click on Option Button 2?

Private Sub OptionButton1_Click()

If OptionButton1.Value = True Then
Me.Range("Y27:AA27").Font.Color = RGB(0, 0, 0)
Else
Me.Range("Y27:AA27").Font.Color = RGB(255, 255, 255)
End If

End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
option button ? Dan Excel Discussion (Misc queries) 6 December 27th 07 08:42 PM
Option Button Pieter van der Walt Excel Worksheet Functions 2 March 27th 06 12:02 PM
keep source formatting is not an option in paste option button Tina Excel Discussion (Misc queries) 0 February 20th 06 09:58 PM
Option Button Help justaguyfromky Excel Discussion (Misc queries) 1 September 5th 05 09:48 PM
option button Mario Excel Discussion (Misc queries) 1 July 26th 05 07:44 PM


All times are GMT +1. The time now is 08:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"