Question : compare two columns then match the text and cell colour

# Column A  has a list of names that have a colour coded cells. These names were present on a day
# Column C has a list of names that were present the next day but the names in column C have no cell colour

I already have a formula in Column B that compares columns A & C and will diplay which names are in both columns (A&C) but I want another Column that will  Compare column C to Column A and if the names in "C" are present in "A" then apply the cell colour from "A" to the matching ref in "C"

n.b. the names do not appear in the same order in column c as they do in column a

Answer : compare two columns then match the text and cell colour

GarethBruce,
You'll need a macro to get the cells in column C to inherit the colors found in matching cells of column A. This macro should be installed in a regular module sheet.

To install a sub in a regular module sheet:
1) ALT + F11 to open the VBA Editor
2) Use the Insert...Module menu item to create a blank module sheet
3) Paste the suggested code in this module sheet
4) ALT + F11 to return to the spreadsheet

To run a sub or macro:
5) ALT + F8 to open the macro window
6) Select the macro
7) Click the "Run" button

Optional steps to assign a shortcut key to your macro:
8) Repeat steps 5 & 6, then press the "Options" button
9) Enter the character you want to use (Shift + character will have fewer conflicts with existing shortcuts)
10) Enter some descriptive text telling what the macro does in the "Description" field
11) Click the "OK" button

If the above procedure doesn't work, then you need to change your macro security setting. To do so, open the Tools...Macro...Security menu item. Choose Medium, then click OK.

Brad
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
Sub Colors()
Dim cel As Range, celA As Range, rgA As Range, rgC As Range
Application.ScreenUpdating = False
Set rgA = Range("A2")   'First cell with names in column A
Set rgA = Range(rgA, Cells(Rows.Count, rgA.Column).End(xlUp))
Set rgC = Range("C2")   'First cell with names in column C
Set rgC = Range(rgC, Cells(Rows.Count, rgC.Column).End(xlUp))
 
For Each cel In rgC.Cells
    If cel <> "" Then
        Set celA = Nothing
        Set celA = rgA.Find(cel, MatchCase:=False, Lookat:=xlWhole)
        If Not celA Is Nothing Then cel.Interior.ColorIndex = celA.Interior.ColorIndex
    End If
Next
Application.ScreenUpdating = True
End Sub
Open in New Window Select All
Random Solutions  
 
programming4us programming4us