需要VBA , 1.按 Alt + F11 打开Excel的VBA编辑器。 2.在“插入”菜单中选择“模块”,插入一个新模块。 3.在模块中粘贴以下代码: Function CountColoredCells(rng As Range, color As Range) As Long Dim cell As Range Dim colorCode As Long Dim count As Long colorCode = color.Interior.Color count = 0 For Each cell In rng If cell.Interior.Color = colorCode Then count = count + 1 End If Next cell CountColoredCells = count End Function