第2个回答 2020-01-22
public
sub
mxbing1984()
r
=
0
y
=
0
g
=
0
x
=
range("a65535").end(xlup).row
for
i
=
1
to
x
cells(i,
1).select
if
selection.font.colorindex
=
3
then
r
=
r
+
1
end
if
if
selection.font.colorindex
=
6
then
y
=
y
+
1
end
if
if
selection.font.colorindex
=
10
then
g
=
g
+
1
end
if
next
sheet2.cells.clear
sheet2.cells(1,
1).value
=
"红色"
sheet2.cells(1,
2).value
=
r
sheet2.cells(2,
1).value
=
"黄色"
sheet2.cells(2,
2).value
=
y
sheet2.cells(3,
1).value
=
"绿色"
sheet2.cells(3,
2).value
=
g
end
sub
统计a列字体的颜色,红色单元格个数r,黄色y,绿色g,结果将放在sheet2工作表
如果统计的是单元格的背景色,则把代码的font改成interior即可.