Option Button Change Cells Text Properties

Oprichnick

Board Regular
Joined
May 30, 2013
Messages
69
Hello, I Have a code for a userform which inserts textboxes and listboxes values each time I press ok, row by row. In the userform I have two optionsbuttons, and I would like that in one of the columns the text to appear red or green dependently what button I've chosed. My code is this: [
Code:
    Dim Rng1 As Range
    Dim NextRow7 As Long
    
    Rng1 = Cells(NextRow7, 8)
    NextRow7 = Application.WorksheetFunction.CountA(Range("H:H")) + 1
    
    If Op1 Then Cells(NextRow4, 4) = "y" 
    If Op1 Then Rng1.Font.ColorIndex = RGB (255,0,0)
It doesn't do anything... (I've just pasted the code I think that may be useful.)

 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
If you want to set the color by RGB use the .Color property:

Code:
Rng1.Font.Color = RGB(255,0,0) 'red
Rng1.Font.Color = RGB(0,255,0) 'green

If you want to use .ColorIndex property then use the integer typed color index:

Code:
Rng1.Font.ColorIndex = 3 'red
Rng1.Font.ColorIndex = 4 'green
 
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,702
Members
452,938
Latest member
babeneker

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
Back
Top