|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
代码试验后,只能显示第一个对比第二个的百分比,当第一个没有数值第二个有数值时就不会显示百分比,求大神们解救!!
For j = 3 To 38
For i = 3 To x
If InStr(Brr(i, j), "百分") = 0 Then s = s + Brr(i, j)
Next i
Brr(x + 1, j) = s
s = 0
Next j
For i = 3 To x + 1
For j = 3 To 38 Step 3
s = s + Brr(i, j)
Next j
Brr(i, 39) = s
s = 0
Next i
For i = 3 To x + 1
For j = 4 To 38 Step 3
s = s + Brr(i, j)
Next j
Brr(i, 40) = s
s = 0
Next i
For i = 3 To x + 1
For j = 5 To 41 Step 3
If Len(Brr(i, j - 2)) > 0 And Brr(i, j - 2) <> 0 Then
bf = Brr(i, j - 1) / Brr(i, j - 2) - 1
Select Case bf
Case Is > 0
Brr(i, j) = "↑" & Format(bf, "0.00%")
Cells(i, j).Font.Color = -11489280
Case Is < 0
Brr(i, j) = "↓" & Format(bf, "0.00%")
Cells(i, j).Font.Color = -16776961
Case Is = 0
Brr(i, j) = "-" & Format(bf, "0.00%")
End Select
End If
Next j
Next i
|
|