Back to Browse

Excel UserForm Data Entry (VBA) #3 - OptionButton

13.8K views
Feb 2, 2014
3:18

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 ws.Cells(newRow, 1).Value = Me.txtFirstName.Value ws.Cells(newRow, 2).Value = Me.txtSurname.Value ws.Cells(newRow, 3).Value = Me.cbCountries.Value 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

Download

0 formats

No download links available.

Excel UserForm Data Entry (VBA) #3 - OptionButton | NatokHD