123 asked in 電腦與網際網路程式設計 · 1 decade ago

如何做百分比彙總表

Type of Drink/1998 Consumption/2000 Consumption/2002 Consumption

Bottled water- 2.5 / 4.1/ 6.7

Dairy/other- 0.3/ 0.3 / 0.3

Juice drinks- 3.1 / 3.7 / 4

Soft drinks- 54 / 53 / 52.5

Sports drinks- 1.9 / 2.2 / 2.5

Tea - 1.9 / 2 / 1.9

Total - 63.7 / 65.3 / 67.9

**************************

如何把這些作成百分比彙總表,如果有人會,是否能告訴我如何做?

1 Answer

Rating
  • 阿戊
    Lv 7
    1 decade ago
    Best Answer

    Private Sub Form_Load()a = "Type of Drink/1998 Consumption/2000 Consumption/2002 Consumption" & vbCrLfa = a & "Bottled water - 2.5 / 4.1 / 6.7" & vbCrLfa = a & "Dairy/other- 0.3/ 0.3 / 0.3" & vbCrLfa = a & "Juice drinks - 3.1 / 3.7 / 4" & vbCrLfa = a & "Soft drinks - 54 / 53 / 52.5" & vbCrLfa = a & "Sports drinks - 1.9 / 2.2 / 2.5" & vbCrLfa = a & "Tea - 1.9 / 2 / 1.9" & vbCrLfa = a & "Total - 63.7 / 65.3 / 67.9"b = Split(a, vbCrLf)For i = 1 To UBound(b) - 1 s = vbTab For j = 0 To 2  s = s & Format(Val(Split(Split(b(i), "-")(1), "/")(j)) / Val(Split(Split(b(UBound(b)), "-")(1), "/")(j)), "0.00%") & vbTab Next j b(i) = b(i) & s Debug.Print b(i)Next iEnd Sub'結果Bottled water - 2.5 / 4.1 / 6.7 3.92%   6.28%   9.87%   Dairy/other- 0.3/ 0.3 / 0.3 0.47%   0.46%   0.44%   Juice drinks - 3.1 / 3.7 / 4    4.87%   5.67%   5.89%   Soft drinks - 54 / 53 / 52.5    84.77%  81.16%  77.32%  Sports drinks - 1.9 / 2.2 / 2.5 2.98%   3.37%   3.68%   Tea - 1.9 / 2 / 1.9 2.98%   3.06%   2.80%  

Still have questions? Get your answers by asking now.