June 25, 2018

Automating Membership Payments with User Form

How to automate membership payments with User Form in Excel.

A charitable organization holds meetings quarterly in January, April, July and October. Members pay their quarterly subscriptions during the meeting. Some may pay for 2 quarters or more. Monthly subscription is Rs. 400 or 400 money units. How can we design a user-form to fill the payment details per month automatically. Watch the video;

Watch this video on YouTube.

Automating Membership Payments with User Form
Automating Membership Payments with User Form

Here’s the complete VBA code to automate membership subscriptions:

Private Sub CommandButton1_Click()
Dim erow As Long
erow = Sheet2.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Dim paymentmonths As Integer
Dim dateofpayment As Date
Dim monthofpayment As Integer
monthofpayment = Month(TextBox2.Value)
paymentmonths = Val(TextBox3.Value) / 400

For i = monthofpayment To (paymentmonths + monthofpayment) – 1
If monthofpayment = 1 Or monthofpayment = 4 Or monthofpayment = 7 Or monthofpayment = 10 Then
Cells(erow, 1).Value = TextBox1.Value
Cells(erow, i + 1) = 400
Else

MsgBox “Meetings are held only in January, April, July and October!”
Exit Sub
End If
Next i

End Sub

Private Sub CommandButton2_Click()
Unload Me
End Sub