如何将Excel中的单元格中的值输出到以日期作为搜索参数的文本框中

时间:2017-03-26 05:29:36

标签: excel vba excel-vba

我在Excel中有这些数据: Excel

我有这个用户表单: user form

我单击日历中的日期,然后在第一张图片中输出该日期下的数据。我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

我们假设您的数据位于单元格D1中。 。 。

Dim dDate As Date 
Private Sub CommandButton1_Click() 
    Sheet1.Range("D1").Value = dDate 
End Sub 

Private Sub TextBox1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean) 

     'Dim dDate As Date
    dDate = DateSerial(Year(Date), Month(Date), Day(Date)) 
    TextBox1.Value = Format(TextBox1.Value, "dd/mm/yyyy") 
    dDate = TextBox1.Value 
End Sub