VBA代码查找日期值

时间:2018-02-25 14:07:24

标签: excel vba excel-vba

在我的Excel中,我有一些日期值,而我的vba代码找不到它。即使使用Ctrl + F,我也无法在Excel工作簿中找到日期。日期写成如下:4-5-2018(d-m-year)

我的vba代码是:

Sub kopieermacro()

' kopieermacro Macro
'
'

    Dim a As String
    Dim b As String
    Dim zoeken As Worksheet
    Dim datum As Date


     ActiveSheet.Range("E2:E18,N2:N18,O2:O18").Copy


     a = Worksheets("Berekenen").OLEObjects("cmbsheet").Object.Value
     Sheets(a).Activate
     datum = CDate(InputBox("voer datum in"))

     Set zoeken = Sheets(a).Cells.Find(What:=(datum))
     If Not zoeken Is Nothing Then
         zoeken.Select
         ActiveCell.Offset(rowoffset:=2, columnoffset:=0).PasteSpecial Paste:=xlPasteValues
     Else
        MsgBox "Zoeken is Nothing"
     End If  
End Sub

0 个答案:

没有答案