Dim a, b, c, d, e, n, m, x, row, col As Integer
Dim lngCount As Long
Dim iRows As Long
With MSFlexGrid2
x = MSFlexGrid1.Rows
lngCount = 1
.Rows = lngCount
.Cols = 2
For m = 1 To x - 2
a = Val(MSFlexGrid1.TextMatrix(m, 0))
b = Val(MSFlexGrid1.TextMatrix(m, 1))
c = Val(MSFlexGrid1.TextMatrix(m + 1, 0))
d = Val(MSFlexGrid1.TextMatrix(m + 1, 1))
e = Int((d - b) / (c - a))
iRows = MSFlexGrid1.Rows
.Rows = .Rows + c - a
MSFlexGrid2.TextMatrix(0, 0) = "高度"
MSFlexGrid2.TextMatrix(0, 1) = "容积"
For n = a To c
.TextMatrix(lngCount - 1, 0) = n
.TextMatrix(lngCount - 1, 1) = (n - a) * e + b
Next n
Next m
End With
你再试试