Change fill color based on the value on sheet2

harky

Active Member
Joined
Apr 8, 2010
Messages
288
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?
 

harky

Active Member
Joined
Apr 8, 2010
Messages
288
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>
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
32,332
Office Version
365
Platform
Windows
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
 

harky

Active Member
Joined
Apr 8, 2010
Messages
288
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
 

harky

Active Member
Joined
Apr 8, 2010
Messages
288
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
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
32,332
Office Version
365
Platform
Windows
Without a macro, yes & you will need a rule for each individual colour.
 

Forum statistics

Threads
1,082,367
Messages
5,365,028
Members
400,819
Latest member
Gossow

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top