Highlight cell same color as matching value vba

katela

New Member
Joined
Mar 24, 2025
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi there!

I am trying to write a macro to reference a list of values (column A on colours tab), find the matching value on another worksheet (column A on Detail tab), resize and highlight (column A to D on detail tab) the same colour as the
original value. END RESULT tab is what I'm trying to get the macro to achieve.
 

Attachments

  • 1000003397.png
    1000003397.png
    75.3 KB · Views: 9
  • 1000003398.png
    1000003398.png
    163.4 KB · Views: 9
  • 1000003399.png
    1000003399.png
    166.5 KB · Views: 9
VBA Code:
Public Sub cond_Frmt()
Dim Rng As Range, Cll As Range
For Each Rng In Worksheets("END RESULT").Range("A2:A13")
 For Each Cll In Worksheets("Coloure").Range("A1:A3")
     If Rng.Value = Cll.Value Then Rng.Resize(1, 4).Interior.Color = Cll.Interior.Color
    Next
Next

End Sub

or
المصنف1
ABCD
1NumberJE#DateAmount
211901/01/2025200
322001/02/2025250
432101/03/2025260
542201/04/2025270
652301/05/2025280
762401/06/2025290
872501/07/2025300
9112601/08/202510
10112701/09/202510
11112801/10/202510
12122901/11/202520
13123001/12/202520
END RESULT
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:D13Expression=MATCH($A2,Coloure!$A$2,0)textNO
A2:D13Expression=MATCH($A2,Coloure!$A$1,0)textNO
 
Upvote 0

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