Mo has attended:
Excel VBA Intro Intermediate course
Radio button not registering a click
Hi,
when I'm clicking between two radio buttons, at one point a click is not registering.
I'm using form controls with a lookup sheet. One macro is assigned to each button with an IF statement.
When I click from option 1 to 2 it's fine, then click back to 1 is fine, then clcik 2 and it doesn't register as a click and the macro doesn't actually run.
The lookup sheet is giving me a value of zero, when it should be 1 or 2.
The code is below and it's not working because of the hide row command, if i comment this out then it will work.
Thanks
Mo
Sub NPSHideRow()
'Hide pivot row
If ThisWorkbook.Sheets("Lookup").Range("H4") = 1 And ThisWorkbook.Sheets("Lookup").Range("C4") = 3 Then
ThisWorkbook.Sheets("NPS Report").Range("j51").Borders.LineStyle = xlNone
ThisWorkbook.Sheets("NPS Report").Range("j51").Delete shift:=xlToLeft
ThisWorkbook.Sheets("NPS Report").Rows("50").Hidden = False
ElseIf ThisWorkbook.Sheets("Lookup").Range("H4") = 2 And ThisWorkbook.Sheets("Lookup").Range("C4") = 3 Then
ThisWorkbook.Sheets("NPS Report").Range("j51").Value = ThisWorkbook.Sheets("NPS Report").Range("j50").Value
With ThisWorkbook.Sheets("NPS Report").Range("j51")
.Borders.LineStyle = xlContinuous
.NumberFormat = "#,###"
End With
ThisWorkbook.Sheets("NPS Report").Rows("50").Hidden = True
End If
End Sub
RE: Radio button not registering a click
Hi Mo, thanks for your query. That's a difficult one to advise you on from afar, I'm afraid because it sounds like the structural changes on the sheet are causing the problems. Try teasing your code out into separate subroutines and altering the visibility of your rows right at the end of the process rather than in the middle of it. Use MsgBoxes to pick up the state of each button at each stage. Other than that, we'd need the spreadsheet to advise further.
Hope this helps,
Anthony