PDA

View Full Version : Solved: Radio button is not working.



doctortt
04-30-2011, 07:28 PM
Hi, what's wrong with my codes?
I have two radio buttons. If a user selects optionbutton1, then it will shade Range("G7:G20") otherwise, shade a different range.

But then I click the radio button, nothing happens.



Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If OptionButton1.Value = True Then
Range("F7:G20").Select
With Selection.Interior
.Pattern = xlLightDown
.PatternColorIndex = xlAutomatic
.ColorIndex = xlAutomatic
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Else
Range("C7:D20").Select
With Selection.Interior
.Pattern = xlLightDown
.PatternColorIndex = xlAutomatic
.ColorIndex = xlAutomatic
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End If

doctortt
04-30-2011, 08:02 PM
If fixed it.

Private Sub OptButton1()
Range("XXXXX").Interior.Pattern = xlLightDown
Range("xxxxx").Interior.Pattern = xlSolid
End If
End Sub
Private Sub OpButton2()
Range("xxxxx").Interior.Pattern = xlLightDown
Range("xxxxx").Interior.Pattern = xlSolid

End Sub

Bob Phillips
05-01-2011, 03:15 AM
You are repeating that code, just assigning a different property. Doesn't seem right to me.

And can't you start using code tags?