Excel UserForm Data Entry (VBA) #3 - OptionButton

preview_player
Показать описание
Learn how to create a simple userform in Excel VBA.
This video shows how to add OptionButton Control.
The code used in this video:
Private Sub btnCancel_Click()
Unload Me
End Sub

Private Sub btnOK_Click()

Dim ws As Worksheet
Set ws = Worksheets("Customers")

Dim newRow As Long
newRow = Application.WorksheetFunction.CountA(ws.Range("A:A")) + 1

If obMale.Value = True Then
ws.Cells(newRow, 4).Value = "Male"
Else
ws.Cells(newRow, 4).Value = "Female"
End If

End Sub

Private Sub UserForm_Initialize()
With cbCountries
.AddItem "Canada"
.AddItem "New Zealand"
End With
End Sub
Рекомендации по теме
Комментарии
Автор

thank you so much it helps a lot for my work

MrCGM
Автор

Thank you so much for no making of this media your stage to feel important. I thank you very much for sharing your knowledge, not getting lost on trivial details, providing excellent information and all and all helping people like me, that don't have the knowledge or time to get it.
If I didn't say it before THANK YOU VERY MUCH. 

nestorsohnlein
Автор

if i want to search my data through user form then how can i search radio button value.
how i can know that it was male or female

aamir