Highlight Cells on a different worksheet if already highlighted (using conditional formatting) on another sheet

sedmonson

New Member
Joined
Apr 14, 2023
Messages
5
Office Version
  1. 365
Platform
  1. Windows
I am attempting to highlight cells where the data matches a different worksheet and these cells are already highlighted. Example; I have Ws1 with several columns of data. Ws1 highlights rows (based on conditional formatting) if a column matches data on Ws2. I now want to highlight Ws3 column E if the data in it matches Ws1 Column E and is highlighted. Since Ws1 highlight is based on conditional formatting, I attempted using various forms of a VBA for "Interior.Color" without any luck.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
If highlighting is done by CF you need to use .DisplayFormat.Interior.Color or .DisplayFormat.Interior.ColorIndex.
 
Upvote 0
Thanks. That got me closer but for some reason it is highlighting the cells on Ws3 that are not highlighted with conditional formatting rather than the ones that are. Below is the current vba. Any ideas what I'm doing wrong?

Sub HighlightMatchedCells()

Dim sourceSheet As Worksheet
Dim targetSheet As Worksheet
Dim sourceRange As Range
Dim targetRange As Range
Dim cell As Range

Set sourceSheet = Worksheets("ECCN BLANK")
Set sourceRange = sourceSheet.Range("E2:E200")

Set targetSheet = Worksheets("EMAILS")
Set targetRange = targetSheet.Range("E2:E100")

For Each cell In targetRange.Cells

If cell.Interior.ColorIndex = sourceRange.Find( _
What:=cell.Value, _
LookIn:=xlValues, _
LookAt:=xlWhole).DisplayFormat.Interior.ColorIndex Then

' Highlight the matched cell
cell.Interior.Color = vbYellow

End If

Next cell

End Sub
 
Upvote 0
Sorry, without a dummy file I can't be of any help. I'm unable to match what you said in post #1 with the range references in your macro.
 
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,217
Members
449,074
Latest member
cancansova

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top