Hi Experts-
I continue to learn VBA. I am stuck on a problem I haven’t found a solution for.
I am using a form to enter data. I need to have the form cleared after clicking OK.
The code below in red is where I am having problems. All the data in textboxes clears fine.
But the data in the combo box isn’t clearing.
Any help you can provide is appreciated.
Private Sub btnOK_Click()
Dim ws As Worksheet
Set ws = Worksheets(“Assets”)
‘If there is nothing in column A then this code will over write anything else that is on the same row.
Dim newRow As Long
newRow = Application.WorksheetFunction.CountA(ws.Range(“A:A”)) + 1
ws.Cells(newRow, 1).Value = Me.txtName.Value
ws.Cells(newRow, 2).Value = Me.txtDateOpened.Value
ws.Cells(newRow, 3).Value = Me.cbAccountType.Value
ws.Cells(newRow, 4).Value = Me.txtAccountNumber.Value
ws.Cells(newRow, 5).Value = Me.txtAmount.Value
ws.Cells(newRow, 6).Value = Me.txtInterestRate.Value
ws.Cells(newRow, 7).Value = Me.txtWeissRating.Value
ws.Cells(newRow, 8).Value = Me.txtDateClosed.Value
ws.Cells(newRow, 9).Value = Me.txtNotes.Value
Dim ctl
For Each ctl In Me.Controls
If TypeOf ctl Is MSForms.TextBox Then
ctl.Text = “”
If TypeOf ctl Is MSForms.ComboBox Then
ctl.Text = “”
End If
End If
Next
End Sub
Private Sub UserForm_Initialize()
With cbAccountType
.AddItem “Savings”
.AddItem “IRA Savings”
.AddItem “Roth Savings”
.AddItem “PM”
End With
End Sub