Follow the same steps as in version #2 before running the macro.
Sub CCC()
Dim rngS As Range
Dim rngT As Range
Dim rng As Range
Dim rng1 As Range
Dim lEndTblRow As Long
Dim lRow As Long
Dim l1stCol As Long
Dim lLstCol As Long
l1stCol = Cells.Find(What:="1 ext", After:=Range("A1"), _
LookIn:=xlFormulas2, LookAt:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Column
lLstCol = Cells(ActiveCell.Row, l1stCol).End(xlToRight).Column
lEndTblRow = Cells(ActiveCell.Row, lLstCol).End(xlDown).Row
Set rngS = Range(Cells(ActiveCell.Row + 1, ActiveCell.Column), Cells(lEndTblRow, ActiveCell.Column))
lRow = Cells.SpecialCells(xlCellTypeLastCell).Row
Set rngT = ActiveCell.End(xlUp).CurrentRegion
Set rngT = Union(rngT, Intersect(Rows(lEndTblRow + 3).Resize(lRow - lEndTblRow - 2), Columns(l1stCol).Resize(, lLstCol - l1stCol + 1)))
For Each rng In rngS
If rng.Font.ColorIndex <> xlAutomatic Then
For Each rng1 In rngT
If rng1.Value = rng.Value Then
rng1.Font.Color = rng.Font.Color
rng1.Font.Bold = True
End If
Next rng1
End If
Next rng
End Sub
Use this macro to remove formatting from the target tables (also select a cell in the source table header)
Sub RemoveFormat()
Dim rngT As Range
Dim lEndTblRow As Long
Dim lRow As Long
Dim l1stCol As Long
Dim lLstCol As Long
l1stCol = Cells.Find(What:="1 ext", After:=Range("A1"), _
LookIn:=xlFormulas2, LookAt:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Column
lLstCol = Cells(ActiveCell.Row, l1stCol).End(xlToRight).Column
lEndTblRow = Cells(ActiveCell.Row, lLstCol).End(xlDown).Row
lRow = Cells.SpecialCells(xlCellTypeLastCell).Row
Set rngT = ActiveCell.End(xlUp).CurrentRegion
Set rngT = Union(rngT, Intersect(Rows(lEndTblRow + 3).Resize(lRow - lEndTblRow - 2), Columns(l1stCol).Resize(, lLstCol - l1stCol + 1)))
rngT.Font.ColorIndex = xlAutomatic
rngT.Font.Bold = False
End Sub
Artik
Bookmarks