A B C D E
1 19 8.0%
2 21 10.5% 21
3 25 19.0%
4 30 20.0%
5 34 13.3% 21 34
6 37 8.8%
7 38 2.7%
8 41 10.8% 41
9 49 19.5%
10 53 8.2% 41 53
vba剛學,程度很差
以C欄的%大小,
1_當 % 增加時,把B欄的值,放到D欄 (但如繼續增加,就不放到D欄)
2_當 % 減少時,把B欄的值,放到E欄 (同樣,但如繼續減少,就不放到E欄)
3_把cells(2,d)中的第1個增加(21),複製到減少的那一列上cells(5,d)
有寫了一些
Sub 比較()
For x = 2 To 1000
If Cells(x + 1, "C") < Cells(x, "C") Then
Cells(x + 1, "D") = Cells(x + 1, "B")
End If
If Cells(x + 1, "C") > Cells(x, "C") Then
Cells(x + 1, "E") = Cells(x + 1, "B")
End If
If Cells(x, "C") = "" Then Exit For
Next x
End Sub
但只能做成這樣
A B C D E
1 19 8.0%
2 21 10.5% 21
3 25 19.0% 25
4 30 20.0% 30
5 34 13.3% 34
6 37 8.8%
7 38 2.7%
8 41 10.8% 41
9 49 19.5% 49
10 53 8.2% 53