PC Review


Reply
Thread Tools Rate Thread

Change color of radio button caption if selected

 
 
HH
Guest
Posts: n/a
 
      30th Mar 2008
I would like the caption font color of a radio button in a group to change
from black to red when selected.
Is that possible and HOW?
Hank



 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      31st Mar 2008
One way is to put the code below behind the OptionButton. It uses
OptionButton1 but you can change it to suit you needs.

Private Sub OptionButton1_GotFocus()
OptionButton1.ForeColor = vbRed
End Sub
Private Sub OptionButton1_LostFocus()
OptionButton1.ForeColor = vbBlack
End Sub

When the control is clicked the font and radio dial area will turn red. When
something else takes focus, the font and radio dial will turn black. Since
you didn't mention where the control is located, sheet or form, I assume it
is from the control tool box. If not, this code is useless. To access the
code window, enter design mode and either double click the OptionButton for
direct access or right click it and then click View Code in the pop up menu.
Paste the above code into the code window.

"HH" wrote:

> I would like the caption font color of a radio button in a group to change
> from black to red when selected.
> Is that possible and HOW?
> Hank
>
>
>
>

 
Reply With Quote
 
HH
Guest
Posts: n/a
 
      1st Apr 2008
Yes, I am using the control too box. The code does change the font to red
but only until I click someplace else on the spreadsheet. The the NO
caption changes back to black. I might not have been clear enough on my
post.

I have 3 radio buttons - YES, NO, and N/A. They are in a group title
Elect. If the NO button is selected I want the font to change from black
to red and stay that way unless the YES or N/A button in that group is
slected. The other buttons should stay never change font colors.

Right now the NO caption stays red utill I click some place else on the
spreadsheet. Then it changes back to black.
Thanks, HH



"JLGWhiz" <(E-Mail Removed)> wrote in message
news:4E8A13CC-9576-4C06-A258-(E-Mail Removed)...
> One way is to put the code below behind the OptionButton. It uses
> OptionButton1 but you can change it to suit you needs.
>
> Private Sub OptionButton1_GotFocus()
> OptionButton1.ForeColor = vbRed
> End Sub
> Private Sub OptionButton1_LostFocus()
> OptionButton1.ForeColor = vbBlack
> End Sub
>
> When the control is clicked the font and radio dial area will turn red.
> When
> something else takes focus, the font and radio dial will turn black.
> Since
> you didn't mention where the control is located, sheet or form, I assume
> it
> is from the control tool box. If not, this code is useless. To access
> the
> code window, enter design mode and either double click the OptionButton
> for
> direct access or right click it and then click View Code in the pop up
> menu.
> Paste the above code into the code window.
>
> "HH" wrote:
>
>> I would like the caption font color of a radio button in a group to
>> change
>> from black to red when selected.
>> Is that possible and HOW?
>> Hank
>>
>>
>>
>>



 
Reply With Quote
 
HH
Guest
Posts: n/a
 
      7th Apr 2008
Anyone there?


"HH" <(E-Mail Removed)> wrote in message
news:aKqIj.28206$(E-Mail Removed)...
> Yes, I am using the control too box. The code does change the font to red
> but only until I click someplace else on the spreadsheet. The the NO
> caption changes back to black. I might not have been clear enough on my
> post.
>
> I have 3 radio buttons - YES, NO, and N/A. They are in a group title
> Elect. If the NO button is selected I want the font to change from
> black to red and stay that way unless the YES or N/A button in that group
> is slected. The other buttons should stay never change font colors.
>
> Right now the NO caption stays red utill I click some place else on the
> spreadsheet. Then it changes back to black.
> Thanks, HH
>
>
>
> "JLGWhiz" <(E-Mail Removed)> wrote in message
> news:4E8A13CC-9576-4C06-A258-(E-Mail Removed)...
>> One way is to put the code below behind the OptionButton. It uses
>> OptionButton1 but you can change it to suit you needs.
>>
>> Private Sub OptionButton1_GotFocus()
>> OptionButton1.ForeColor = vbRed
>> End Sub
>> Private Sub OptionButton1_LostFocus()
>> OptionButton1.ForeColor = vbBlack
>> End Sub
>>
>> When the control is clicked the font and radio dial area will turn red.
>> When
>> something else takes focus, the font and radio dial will turn black.
>> Since
>> you didn't mention where the control is located, sheet or form, I assume
>> it
>> is from the control tool box. If not, this code is useless. To access
>> the
>> code window, enter design mode and either double click the OptionButton
>> for
>> direct access or right click it and then click View Code in the pop up
>> menu.
>> Paste the above code into the code window.
>>
>> "HH" wrote:
>>
>>> I would like the caption font color of a radio button in a group to
>>> change
>>> from black to red when selected.
>>> Is that possible and HOW?
>>> Hank
>>>
>>>
>>>
>>>

>
>



 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      7th Apr 2008
Try this

Private Sub OptionButton1_Change()

With OptionButton1
If .Value Then
.ForeColor = vbRed ' or RGB(255, 0, 0)
Else
.ForeColor = vbWindowText ' or RGB(0,0,0)
End If
End With

End Sub

and similar for the other two option buttons

Regards,
Peter T

"HH" <(E-Mail Removed)> wrote in message
news:aKqIj.28206$(E-Mail Removed)...
> Yes, I am using the control too box. The code does change the font to red
> but only until I click someplace else on the spreadsheet. The the NO
> caption changes back to black. I might not have been clear enough on my
> post.
>
> I have 3 radio buttons - YES, NO, and N/A. They are in a group title
> Elect. If the NO button is selected I want the font to change from

black
> to red and stay that way unless the YES or N/A button in that group is
> slected. The other buttons should stay never change font colors.
>
> Right now the NO caption stays red utill I click some place else on the
> spreadsheet. Then it changes back to black.
> Thanks, HH
>
>
>
> "JLGWhiz" <(E-Mail Removed)> wrote in message
> news:4E8A13CC-9576-4C06-A258-(E-Mail Removed)...
> > One way is to put the code below behind the OptionButton. It uses
> > OptionButton1 but you can change it to suit you needs.
> >
> > Private Sub OptionButton1_GotFocus()
> > OptionButton1.ForeColor = vbRed
> > End Sub
> > Private Sub OptionButton1_LostFocus()
> > OptionButton1.ForeColor = vbBlack
> > End Sub
> >
> > When the control is clicked the font and radio dial area will turn red.
> > When
> > something else takes focus, the font and radio dial will turn black.
> > Since
> > you didn't mention where the control is located, sheet or form, I assume
> > it
> > is from the control tool box. If not, this code is useless. To access
> > the
> > code window, enter design mode and either double click the OptionButton
> > for
> > direct access or right click it and then click View Code in the pop up
> > menu.
> > Paste the above code into the code window.
> >
> > "HH" wrote:
> >
> >> I would like the caption font color of a radio button in a group to
> >> change
> >> from black to red when selected.
> >> Is that possible and HOW?
> >> Hank
> >>
> >>
> >>
> >>

>
>



 
Reply With Quote
 
HH
Guest
Posts: n/a
 
      7th Apr 2008
Exactly what I needed - It pays to ask the question right!
Thanks

"Peter T" <peter_t@discussions> wrote in message
news:(E-Mail Removed)...
> Try this
>
> Private Sub OptionButton1_Change()
>
> With OptionButton1
> If .Value Then
> .ForeColor = vbRed ' or RGB(255, 0, 0)
> Else
> .ForeColor = vbWindowText ' or RGB(0,0,0)
> End If
> End With
>
> End Sub
>
> and similar for the other two option buttons
>
> Regards,
> Peter T
>
> "HH" <(E-Mail Removed)> wrote in message
> news:aKqIj.28206$(E-Mail Removed)...
>> Yes, I am using the control too box. The code does change the font to
>> red
>> but only until I click someplace else on the spreadsheet. The the NO
>> caption changes back to black. I might not have been clear enough on my
>> post.
>>
>> I have 3 radio buttons - YES, NO, and N/A. They are in a group title
>> Elect. If the NO button is selected I want the font to change from

> black
>> to red and stay that way unless the YES or N/A button in that group is
>> slected. The other buttons should stay never change font colors.
>>
>> Right now the NO caption stays red utill I click some place else on the
>> spreadsheet. Then it changes back to black.
>> Thanks, HH
>>
>>
>>
>> "JLGWhiz" <(E-Mail Removed)> wrote in message
>> news:4E8A13CC-9576-4C06-A258-(E-Mail Removed)...
>> > One way is to put the code below behind the OptionButton. It uses
>> > OptionButton1 but you can change it to suit you needs.
>> >
>> > Private Sub OptionButton1_GotFocus()
>> > OptionButton1.ForeColor = vbRed
>> > End Sub
>> > Private Sub OptionButton1_LostFocus()
>> > OptionButton1.ForeColor = vbBlack
>> > End Sub
>> >
>> > When the control is clicked the font and radio dial area will turn red.
>> > When
>> > something else takes focus, the font and radio dial will turn black.
>> > Since
>> > you didn't mention where the control is located, sheet or form, I
>> > assume
>> > it
>> > is from the control tool box. If not, this code is useless. To access
>> > the
>> > code window, enter design mode and either double click the OptionButton
>> > for
>> > direct access or right click it and then click View Code in the pop up
>> > menu.
>> > Paste the above code into the code window.
>> >
>> > "HH" wrote:
>> >
>> >> I would like the caption font color of a radio button in a group to
>> >> change
>> >> from black to red when selected.
>> >> Is that possible and HOW?
>> >> Hank
>> >>
>> >>
>> >>
>> >>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change default caption color in References/Insert Caption? Nick Piazza Microsoft Word Document Management 4 13th Jul 2009 07:00 PM
Unprotect Cells When Radio Button Selected Rick Microsoft Excel Programming 1 18th Sep 2008 06:14 AM
Change color for radio button =?Utf-8?B?Um95?= Microsoft Dot NET Framework 1 27th Jun 2007 08:04 AM
How do I lock a radio button group if a N/A button is selected =?Utf-8?B?d29ycnkgYSBsb3Q=?= Microsoft Excel Misc 2 21st May 2005 08:33 PM
Add Email addres if Radio Button is Selected Riz Microsoft Outlook Form Programming 1 20th Jul 2004 05:07 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:41 PM.