|
Public Sub CouShu2()
Dim t#, n%, x%, m%, dj, i&, j&, k%, slmax&, slmin&, sy, sysl, zd
Dim csje#, sjje#, rxwc#, pd As Boolean, rng As Range
t = Timer
With 开票明细
.Range("f11:f18").ClearContents
pd = False
n = .Range("b1").Value
csje = .Range("b2").Value
x = WorksheetFunction.CountIf(Range("m:m"), "√")
m = WorksheetFunction.Min(n, x)
If m = 0 Then Exit Sub
ReDim sl(1 To m, 1 To 1), dj(1 To m)
k = 0
For Each rng In .Range("e11:e" & 10 + m)
k = k + 1
dj(k) = rng.Value
Next rng
sy = csje
sjje = 0
For j = 1 To m - 1
zd = i
sl(j, 1) = Round(csje / (3 * dj(j)), 3)
sy = sy - dj(j) * sl(j, 1)
sjje = sjje + dj(j) * sl(j, 1)
Next j
sysl = sy / dj(m)
sl(m, 1) = Round(sysl, 3)
.Range("f11").Resize(m, 1) = sl
.Range("b3").Value = .Range("g19").Value - .Range("b2").Value '实际误差
End With
End Sub
多数情况是不容易找的答案的,因为你限定了吨的位数,如果实际生活中确有这样的数值,也就是说你的金额是根据具体吨数计算得出的,那么可以按《数论》这本书上的相关内容来解答出吨数,是很繁琐的。 |
|