ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   radio button help (https://www.excelbanter.com/excel-worksheet-functions/47403-radio-button-help.html)

tjb

radio button help
 
What I want is if the radio button (named "VolorInvol") is selected, it
performs the formula in the cell, if the radio button is not marked I want
the cell to be blank. Here's my code but it doesn't work, what am I doing
wrong?

There are several other radio buttons in this same group so a checkbox won't
work for this situation.

Private Sub VolorInvol_Click()
If VolorInvol.Value = True Then
Range("B14").Formula = "=DATE(YEAR(EVENT),MONTH(EVENT)+1,0)"
Else
Range("B14").Value = ""
End If
End Sub

Rowan

Hi

Did you not see my earlier reply?

What you are doing wrong is that the event (macro) you have here will
only run when the radio button VolorInvol is clicked. Clicking a radio
button "turns is on" making its vba value True. Therefore you code can
only ever enter the formula in B14. It will never remove the formula.

You need to add the line of code:
Range("B14").Value = ""
to the click event for all the other buttons in order to remove the
formula from B14 when VolorInvol is not checked.

Regards
Rowan

tjb wrote:
What I want is if the radio button (named "VolorInvol") is selected, it
performs the formula in the cell, if the radio button is not marked I want
the cell to be blank. Here's my code but it doesn't work, what am I doing
wrong?

There are several other radio buttons in this same group so a checkbox won't
work for this situation.

Private Sub VolorInvol_Click()
If VolorInvol.Value = True Then
Range("B14").Formula = "=DATE(YEAR(EVENT),MONTH(EVENT)+1,0)"
Else
Range("B14").Value = ""
End If
End Sub



All times are GMT +1. The time now is 04:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com