如何给不同颜色的重复单元格组上色?

A列有:

table pencil table table paper pencil paper 

所以,所有含有table单元应该有黄色, pencil应该是蓝色的,而paper应该是红色的,

这个怎么做?

给你的input范围名称“参数”

创build另一个范围“模板”,在其中列出每个元素一次,并以您喜欢的方式(边框,样式,背景颜色等)进行格式化。

运行下面的代码

 Sub FormatFromList() Dim ArgCell As Range, TemplateCell As Range For Each ArgCell In Range("Argument").Cells For Each TemplateCell In Range("Template").Cells If ArgCell = TemplateCell Then TemplateCell.Copy ArgCell.PasteSpecial xlPasteFormats Exit For End If Next TemplateCell Next ArgCell End Sub 

如果您想要更多自动化,请考虑使用Worksheet_Change(...)触发器来调用FormatFromList()