prasadksu
03-29-2009, 12:46 PM
hello everyone,
I am new to VBA programming. I created an user form and there are three option buttons (daily, monthly and yearly) grouped in a frame so that the user can choose only one of the options. For example if the user chooses daily button, then in cell A1, 1 should be printed and if the user chooses monthly option, then in cell A2, 30 should print and for yearly option, in cellA3, 360 should print. I tried doing using the following code but i was not succesful....
Private Sub CommandButton1_Click()
If optdaily = True Then
ThisWorkbook.Worksheets("sheet1").Range("A1").Value = "1"
ElseIf optmonthly = True Then
ThisWorkbook.Worksheets("sheet1").Range("A2").Value = "30"
Else
ThisWorkbook.Worksheets("sheet1").Range("A3").Value = "360"
End If
End Sub
I would be verythankful if anyone could correct the code......
Thanks,
Prasad.
I am new to VBA programming. I created an user form and there are three option buttons (daily, monthly and yearly) grouped in a frame so that the user can choose only one of the options. For example if the user chooses daily button, then in cell A1, 1 should be printed and if the user chooses monthly option, then in cell A2, 30 should print and for yearly option, in cellA3, 360 should print. I tried doing using the following code but i was not succesful....
Private Sub CommandButton1_Click()
If optdaily = True Then
ThisWorkbook.Worksheets("sheet1").Range("A1").Value = "1"
ElseIf optmonthly = True Then
ThisWorkbook.Worksheets("sheet1").Range("A2").Value = "30"
Else
ThisWorkbook.Worksheets("sheet1").Range("A3").Value = "360"
End If
End Sub
I would be verythankful if anyone could correct the code......
Thanks,
Prasad.