我有一张包含多张纸的工作簿。在表格"团队"我有一个每个团队的列表,每个单元格都有不同的背景和字体颜色。我想要另一张表(名为" 1")查看" Teams"上的列表,如果值匹配,则匹配背景和字体颜色。使用VBA和这个站点,我使用以下方法获得了背景颜色:
Sub MatchHighlight()
Dim wsHighlight As Worksheet
Dim wsData As Worksheet
Dim rngColor As Range
Dim rngFound As Range
Dim KeywordCell As Range
Dim strFirst As String
Set wsHighlight = Sheets("Teams")
Set wsData = Sheets("1")
With wsData.Columns("C")
For Each KeywordCell In wsHighlight.Range("C2", wsHighlight.Cells(Rows.Count, "C").End(xlUp)).Cells
Set rngFound = .Find(KeywordCell.Text, .Cells(.Cells.Count), xlValues, xlWhole)
If Not rngFound Is Nothing Then
strFirst = rngFound.Address
Set rngColor = rngFound
Do
Set rngColor = Union(rngColor, rngFound)
Set rngFound = .Find(KeywordCell.Text, rngFound, xlValues, xlWhole)
Loop While rngFound.Address <> strFirst
rngColor.Interior.Color = KeywordCell.Interior.Color
End If
Next KeywordCell
End With
End Sub
有没有办法修改此代码(或使用其他代码)来检索字体颜色?提前感谢您的任何见解。
答案 0 :(得分:0)
只需添加另一行
rngColor.Font.Color = KeywordCell.Font.Color