我在尝试运行代码时收到运行时错误“13”:类型不匹配。调试突出显示“IF”和“ElseIF”语句,但我不知道错误在哪里。任何帮助,将不胜感激。谢谢
Dim lColumn As Long
lColumn = ws.Cells(2, Columns.Count).End(xlToLeft).Column
Dim rgMonth As Range
Dim rgTaxExp As Range
Dim i As Long, j As Long
Set rgTaxExp = Range(Cells(lRow, 10), Cells(lRow, lColumn))
Set rgMonth = Range(Cells(2, 10), Cells(2, lColumn))
For i = 1 To rgMonth.Rows.Count
For j = 1 To rgMonth.Columns.Count
If Month(date2) >= Month(rgMonth.Cells(i, j).Value) Then 'Runtime Error '13':_
Type Mismatch
Cells(lRow, 9).Copy rgTaxExp.Cells(i, j)
ElseIf Month(date2) < Month(rgMonth.Cells(i, j).Value) Then 'Runtime Error '13':_
Type Mismatch
rgTaxExp.Cells(i, j) = 0