我有一张多张工作簿 . 在工作表“团队”中,我有一个每个团队的列表,每个单元格都有不同的背景和字体颜色 . 我希望另一张表( Headers 为“1”)查看“团队”上的列表,如果值匹配,则匹配背景和字体颜色 . 使用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
有没有办法修改此代码(或使用其他代码)来检索字体颜色?提前感谢您的任何见解 .
1 回答
只需添加另一行