由于类型不匹配,此代码在For
循环中返回错误:
Dim sp, q, spb, spt, cp, cpb, cpt, g, n, i As String
n = Range("G3").Value
cp = ActiveCell.Offset(0, -4).Value
q = ActiveCell.Offset(0, -3).Value
cpt = cp * q
cpb = cp * n
i = 0.05
For i = 0.05 To 10
sp = cp + i
spt = (sp * q)
spb = spt * n
g = spt - cpt - spb - cpb
If g > 0 Then
Range("I10").Value = g
Exit For
End If
Next i
End Sub