请帮我优化VBA代码,一运行堆栈溢出,Dim o As Range: Set o = Range("I2:J24"),提示这句,谢谢
PrivateSubWorksheet_Change(ByValTargetAsRange)DimXDimX1DimX2DimX3DimoAsRange:Seto=Ran...
Private Sub Worksheet_Change(ByVal Target As Range)
Dim X
Dim X1
Dim X2
Dim X3
Dim o As Range: Set o = Range("I2:J24")
X = Target.Row
If Cells(X, 3) <> "" Then
X1 = Application.VLookup(Range("A" & X), o, 2, False)
X2 = Application.VLookup(Range("D" & X), o, 2, False)
X3 = Cells(X, 5) / X2 * X1
Cells(X, 7) = (X3 - Cells(X, 6)) * (Cells(X, 3) - Cells(X, 2)) * 1440 / 60
Else
Cells(X, 7) = 0
End If
End Sub 展开
Dim X
Dim X1
Dim X2
Dim X3
Dim o As Range: Set o = Range("I2:J24")
X = Target.Row
If Cells(X, 3) <> "" Then
X1 = Application.VLookup(Range("A" & X), o, 2, False)
X2 = Application.VLookup(Range("D" & X), o, 2, False)
X3 = Cells(X, 5) / X2 * X1
Cells(X, 7) = (X3 - Cells(X, 6)) * (Cells(X, 3) - Cells(X, 2)) * 1440 / 60
Else
Cells(X, 7) = 0
End If
End Sub 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询