Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
excel16:vba,如何从组合框中选择日期dd/mm/yyyy并更新单元格_Vba_Excel_Excel 2016 - Fatal编程技术网

excel16:vba,如何从组合框中选择日期dd/mm/yyyy并更新单元格

excel16:vba,如何从组合框中选择日期dd/mm/yyyy并更新单元格,vba,excel,excel-2016,Vba,Excel,Excel 2016,请帮忙。。。在excel V16表单中, 我添加了输入日期和上次付款日期的组合框,设置为DD/MM/YYYY,默认值为: 年(2000年至2020年)月(1日至31日)/MM(1日至12日)/YYYY 用户可以输入一个studentID,然后单击搜索,从sheet1中检索数据,并用所需的值填写表单 我得到以下问题: 1.搜索现有记录后,组合框DD/MM/YYYY中未加载存储在单元格Q输入日期和单元格X上次付款日期中的数据。 2.更新日期(DD/MM/YYYY)数据时,它不会在单元格Q&X中复制

请帮忙。。。在excel V16表单中, 我添加了输入日期和上次付款日期的组合框,设置为DD/MM/YYYY,默认值为: 年(2000年至2020年)月(1日至31日)/MM(1日至12日)/YYYY

用户可以输入一个studentID,然后单击搜索,从sheet1中检索数据,并用所需的值填写表单

我得到以下问题: 1.搜索现有记录后,组合框DD/MM/YYYY中未加载存储在单元格Q输入日期和单元格X上次付款日期中的数据。 2.更新日期(DD/MM/YYYY)数据时,它不会在单元格Q&X中复制

请帮助宏

搜索和更新btn的代码:

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

请在实际问题中插入代码并删除链接。没有人想(或者可能会)点击你的链接并打开你的文件。好的。为搜索和更新btn添加的代码。但我在创建新文本框时添加的这段代码将隐藏在表单中。它连接选定的组合框值。是否有其他方法可以从DD/MM/YYYY组合中选择值来更新所需的单元格?当单击搜索btn时,它应该从单元格中重新填充组合框wz ze values。。有什么想法吗?