我有一本有两张纸的工作簿。在工作表A上,我更改了某些单元格的内部颜色。我想在工作表B中找到具有匹配文本的单元格,并将它们设置为具有相同的内部颜色。但是,到达时hRow = Application...
,我收到一个错误,The application does not support this object or property.
我一直在寻找类似的函数,但是在没有循环遍历范围中的每个单元格的情况下,找不到一种匹配文本的好方法并没有成功。
Public Sub MatchHighlight()
Dim lRow As Integer
Dim i As Integer
Dim hRow As Integer
Dim LookUpRange As Range
Set LookUpRange = Worksheets("HR - Highlight").Range("C2:C104")
Dim compare As Range
Set compare = Worksheets("Full List").Range("C2:C277")
lRow = Worksheets("Full List").UsedRange.Rows.Count
For i = 2 To lRow
hRow = Application.Worksheets("Full List").WorksheetFunction.Match(compare.Range("C" & i).Text, LookUpRange, 0)
If Not IsNull(hRow) Then
compare.Range("C" & i).Interior.Color = LookUpRange.Range("C" & hRow).Interior.Color
End If
Next i
结束子
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("HR - Highlight")
Set wsData = Sheets("Full List")
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
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句