在VBA里这段程序只有引用中间段数据的时候可用,前面数据运算显示除数为0,后面的数据运算显示溢出
PrivateSubcmd_Click()Dimarr()AsVariantDimindex1AsVariant,index2AsVariant,gdp1AsVarian...
Private Sub cmd_Click()
Dim arr() As Variant
Dim index1 As Variant, index2 As Variant, gdp1 As Variant, gdp2 As Variant, i, j
arr = Range("A1:C62")
For i = LBound(arr) To UBound(arr)
If a.Value = arr(i, 1) Then
gdp1 = arr(i, 2)
index1 = arr(i, 3)
End If
Next i
For j = LBound(arr) To UBound(arr)
If b.Value = arr(j, 1) Then
gdp2 = arr(j, 2)
index2 = arr(j, 3)
End If
Next j
c.Value = (index1 / index2) * gdp2
d.Value = gdp1 / ((index1 / index2) * gdp2)
End Sub 展开
Dim arr() As Variant
Dim index1 As Variant, index2 As Variant, gdp1 As Variant, gdp2 As Variant, i, j
arr = Range("A1:C62")
For i = LBound(arr) To UBound(arr)
If a.Value = arr(i, 1) Then
gdp1 = arr(i, 2)
index1 = arr(i, 3)
End If
Next i
For j = LBound(arr) To UBound(arr)
If b.Value = arr(j, 1) Then
gdp2 = arr(j, 2)
index2 = arr(j, 3)
End If
Next j
c.Value = (index1 / index2) * gdp2
d.Value = gdp1 / ((index1 / index2) * gdp2)
End Sub 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询