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

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
There are many data on sheet1 & 2 but i will show 5 here for example

Sheet1
Col A
0.1
0.2
0.3
0.4
0.5

<tbody>
</tbody>

I dunno how to put fill colour here.

Sheet2
Col A
0.1
0.2
0.3
0.4
0.5

<tbody>
</tbody>
 
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,213,536
Messages
6,114,215
Members
448,554
Latest member
Gleisner2

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