Change fill color based on the value on sheet2

harky

Active Member
Joined
Apr 8, 2010
Messages
405
Office Version
  1. 2021
  2. 2019
Platform
  1. Windows
Sheet1 is data
Sheet2 is data with fill color

Abit hard to use conditional Formatting as i have at least 411 data with fill color


Is there anyway to do it?
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
There are many data on sheet1 & 2 but i will show 5 here for example

Sheet1
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Col A[/TD]
[/TR]
[TR]
[TD]0.1[/TD]
[/TR]
[TR]
[TD]0.2[/TD]
[/TR]
[TR]
[TD]0.3[/TD]
[/TR]
[TR]
[TD]0.4[/TD]
[/TR]
[TR]
[TD]0.5[/TD]
[/TR]
</tbody>[/TABLE]

I dunno how to put fill colour here.

Sheet2
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Col A[/TD]
[/TR]
[TR]
[TD]0.1 [/TD]
[/TR]
[TR]
[TD]0.2[/TD]
[/TR]
[TR]
[TD]0.3[/TD]
[/TR]
[TR]
[TD]0.4[/TD]
[/TR]
[TR]
[TD]0.5[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
How about
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   Dim Fnd As Range
   
   If Target.CountLarge > 1 Then Exit Sub
   If Target.Column = 1 Then
      Set Fnd = Sheets("Sheet2").Range("A:A").Find(Target.Value, , xlValues, xlWhole, , , False, , False)
      If Fnd Is Nothing Then
         Target.Interior.Color = xlNone
      Else
         Target.Interior.Color = Fnd.Interior.Color
      End If
   End If
End Sub
 
Upvote 0
thanks!
was thinking if possible, dont want to use macro.

Is conditional format the only way?

How about
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   Dim Fnd As Range
   
   If Target.CountLarge > 1 Then Exit Sub
   If Target.Column = 1 Then
      Set Fnd = Sheets("Sheet2").Range("A:A").Find(Target.Value, , xlValues, xlWhole, , , False, , False)
      If Fnd Is Nothing Then
         Target.Interior.Color = xlNone
      Else
         Target.Interior.Color = Fnd.Interior.Color
      End If
   End If
End Sub
 
Upvote 0
Think i use this. Thanks bro!

How about
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   Dim Fnd As Range
   
   If Target.CountLarge > 1 Then Exit Sub
   If Target.Column = 1 Then
      Set Fnd = Sheets("Sheet2").Range("A:A").Find(Target.Value, , xlValues, xlWhole, , , False, , False)
      If Fnd Is Nothing Then
         Target.Interior.Color = xlNone
      Else
         Target.Interior.Color = Fnd.Interior.Color
      End If
   End If
End Sub
 
Upvote 0
Without a macro, yes & you will need a rule for each individual colour.
 
Upvote 0

Forum statistics

Threads
1,224,737
Messages
6,180,653
Members
452,992
Latest member
TokugawaIesuma

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