vendredi 28 mai 2021

How do I add check box in Form to show payment date?

This is what I have in my Payment Form. I use a Combobox to pull the user info into the payments Form. The trouble I am having is it keeps showing TRUE in the Paid column. In another column to the right of Paid it shows 30 days out when next payment is due.

I've tried this code but it puts it in all the cells in the column


If CheckBox1.Value = True Then
    Range("I:I").Value = Date
    Else: Range("I:I").Value = ""
End If

End Sub```



'Dim xRg As Range
'Updated by Extendoffice 2018/1/30
Private Sub Userform_Initialize()
    Set xRg = Worksheets("Customer").Range("A2:F8")
    ComboBox1.List = xRg.Columns(1).Value
End Sub
Private Sub ComboBox1_Change()
    TextBox1.Text = Application.WorksheetFunction.VLookup(ComboBox1.Value, xRg, 2, False)
    TextBox2.Text = Application.WorksheetFunction.VLookup(ComboBox1.Value, xRg, 3, False)
    TextBox3.Text = Application.WorksheetFunction.VLookup(ComboBox1.Value, xRg, 4, False)
    TextBox4.Text = Application.WorksheetFunction.VLookup(ComboBox1.Value, xRg, 5, False)
    TextBox5.Text = Application.WorksheetFunction.VLookup(ComboBox1.Value, xRg, 6, False)
End Sub
Private Sub cbCancel_Click()
    Unload Me
End Sub

Private Sub cbAdd_Click()

'dimmin Var
    Dim Data As Worksheet

'Setting Var
    Set Data = ThisWorkbook.Sheets("Payments")
    NextRow = Data.Cells(Rows.Count, 1).End(xlUp).Row + 1
    
    Data.Cells(NextRow, 1) = Me.ComboBox1.Value
    Data.Cells(NextRow, 2) = Me.TextBox1.Value
    Data.Cells(NextRow, 3) = Me.TextBox2.Value
    Data.Cells(NextRow, 4) = Me.TextBox3.Value
    Data.Cells(NextRow, 5) = Me.TextBox4.Value
    Data.Cells(NextRow, 7) = Me.CheckBox1.Value
    
    Me.TextBox1.Value = ""
    Me.TextBox2.Value = ""
    Me.TextBox3.Value = ""
    Me.TextBox4.Value = ""
    Me.ComboBox1.Value = ""
    Me.CheckBox1.Value = ""
    
End Sub

Private Sub CommandButton2_Click()
Dim ctl As Control
For Each ctl In Me.Controls
If TypeName(ctl) = “TextBox” Or TypeName(ctl) = “ComboBox” Then
ctl.Value = “”
End If
Next ctl
End Sub```



Aucun commentaire:

Enregistrer un commentaire