【发布时间】:2015-05-08 19:34:39
【问题描述】:
我正在使用 VBA for Excel。 每次运行此代码时,我都会收到“应用程序定义或对象定义”错误。 这里是:
Sub Test()
Dim i As Integer, j As Integer, k As Integer, l As Integer, t As Integer
Dim row As Integer
Dim Maturite As Integer
Dim tsup As Double, tinf As Double
Dim datetaux As Date, datejouissance As Date
Dim taux As Double
For i = 2 To 770
Maturite = Sheets("Em").Cells(i, 19)
datejouissance = Sheets("Em").Cells(i, 14)
For l = 2 To 255
For k = 0 To 10
For t = 1 To 10
row = 13 * k + 2
datetaux = Sheets("TSR").Cells(row, l)
taux = Sheets("TSR").Cells(13 * k + 3, l)
If taux <> 0 Then
If datejouissance = datetaux Then
If 91 <= Maturite And Maturite <= 182 Then
tsup = Sheets("TSR").Cells(row + 2, j)
tinf = Sheets("TSR").Cells(row + 1, j)
Sheets("Em").Cells(i, 21).Value = ((tsup - tinf) * (Maturite - 91) / (182 - 91)) + tinf
End If
End If
End If
Next
Next
Next
Next
End Sub
我在以下位置收到错误:
tsup = Sheets("TSR").Cells(row + 2, j)
我尝试使用:
tsup = Sheets("TSR").Cells(row + 2, j).Value
Sheets("TSR").Cells(row + 2, j).Value 的类型是 Double。 但它不起作用。我似乎无法理解问题所在。
提前致谢
【问题讨论】:
-
您能否显示
Em和TSR表格的屏幕截图,以便我们了解单元格的排列方式?