excel: vba type mismatch comparing dates

前端 未结 1 1042
逝去的感伤
逝去的感伤 2021-01-20 18:45

I\'m trying to make a comparison between years from two dates (in different columns) and the current year date. If the year is the same then it should write on the correspon

相关标签:
1条回答
  • 2021-01-20 19:17

    Try this:

    1. Declare date variables Dim date1 As Date, date2 As Date
    2. Set value for variable

      date1 = ws1.Cells(j, 9) date2 = ws1.Cells(j, 12)

    3. Use variable in your If statement

      If Year(date1) = Year(Date) Or Year(date2) = Year(Date) Then

    0 讨论(0)
提交回复
热议问题