|
5学分
急求表格中数星星程序,领导开会每周对各门店的各工作项评星,有红星,黑星,且前面有数字表示星的数量,表很多人做,红与黑的颜色不是完全统一,如有的人用深红,有的用粉红,如何电脑全自动统计黑星及红星的数量,要完整代码,谢谢!具体看模板中第一行数据统计是对的,其余统计都是错的!
- Sub A()
- Dim RG As Range
- Dim X, Y
- Dim 红, 黑
- For Each RG In Range("B3:P23")
- If RG.Characters(1, 3).Font.ColorIndex > 0 Then
- RG.Characters(1, 3).Font.ColorIndex = 3
- Else
- RG.Characters(1, 3).Font.ColorIndex = -4105
- End If
- Next
- For X = 3 To 23
- For Y = 2 To 15
- If Cells(X, Y).Characters(1, 3).Font.ColorIndex = 3 Then
- 红 = 红 + Val(VBA.Left(Cells(X, Y), 1))
- ElseIf Cells(X, Y).Characters(1, 3).Font.ColorIndex = -4105 Then
- 黑 = 黑 + Val(VBA.Left(Cells(X, Y), 1))
- End If
- Next
- Cells(X, "Q") = 红
- Cells(X, "R") = 黑
- 红 = 0
- 黑 = 0
- Next
- End Sub
复制代码
|
|