请帮助...在 excel V16 表单中, 我添加了输入日期和上次付款日期的组合框,设置为DD/MM/YYYY,默认为值: DD(01至31(/MM(01至12(/YYYY(2000至2020(
用户可以输入学生ID,然后单击搜索,从sheet1中检索数据,并在表格中填写所需的值。
我遇到了以下问题: 1.搜索现有记录后,组合框DD/MM/YYYYY不会加载存储在单元格Q输入日期和单元格X上次付款日期中的数据。 2. 更新日期 (DD/MM/YYYY( 数据时,它不会在单元格 Q & X 中复制。
请帮助宏 https://drive.google.com/drive/folders/1k8UKQQOS8tWa7I-wucEgIA5ypN6MFPOq?usp=sharing
搜索和更新代码:
Private Sub txt_date_Change()
txt_date.Text = cbo_dd.Value & "/" & cbo_mm.Value & "/" & cbo_yy.Value
End Sub
Private Sub cmd_search_Click()
Dim lastrow
Dim ref As String
Sheets("sheet1").Activate
lastrow = Sheets("sheet1").Range("A" & Rows.Count).End(xlUp).Row
ref = txt_ref.Text
For currentrow = 2 To lastrow
If Cells(currentrow, 1).Text = ref Then
'txt_date.Text = Cells(currentrow, 17).Text
txt_datein.Text = Cells(currentrow, 17).Text 'date of entry
txt_dateout.Text = Cells(currentrow, 24).Value 'date last payment
Exit For
End If
Next currentrow
txt_datein.Enabled = False
txt_date.Enabled = False
End Sub
Private Sub cmd_update_Click()
Dim ref As String, cir As String
Sheets("sheet1").Activate
datein = txt_datein.Text
Cells(currentrow, 17).Value = datein
dateout = txt_dateout.Text
Cells(currentrow, 24).Value = dateout
With Me.cbo_mm
.Clear
.AddItem "01"
.AddItem "02"
.AddItem "03"
.AddItem "04"
.AddItem "05"
.AddItem "06"
.AddItem "07"
.AddItem "08"
.AddItem "09"
.AddItem "10"
.AddItem "11"
.AddItem "12"
End With
With Me.cbo_yy
.Clear
.AddItem "2018"
.AddItem "2019"
.AddItem "2020"
End With
Call clear_all
End Sub
从 UserForm1 代码中删除以下内容:
Private Sub txt_date_Change()
txt_date.Text = cbo_dd.Value & "/" & cbo_mm.Value & "/" & cbo_yy.Value
End Sub