Highlighting values from list in range?

afc171

Board Regular
Joined
Jan 14, 2017
Messages
143
Office Version
  1. 2013
Platform
  1. Windows
Hi all,

It it possible to highlight the rows from A to J which match the numbers under column U in different colors?

So if 4200323937 appears in column I, highlight green. If 4200323083 appears highlight orange etc

ProductPath2.xlsm
ABCEFGHIJKTU
1PRODUCTQTYBATCHDOCUMENTBINWhs OrderHUPurchase OrdersBinPPurchase Orders
2prod12INN180111081589KDBCAT0430001039801111111101603560004200324186184200323937
3prod21616154411081538KDBCAT0530001039741111111101603520004200323937194200323083
4prod31616069411081589KDBCAT0630001039801111111101603560004200324186204200321357
5prod4106458918311081587KDB1000130001039781111111101603540004200319010214200324404
6prod5126458825611076762KDB1000230001040371111111101602860004200322121224200324186
7prod6410000698311087005KDB1000230001039901111111101604120004200323937224200322121
8prod736459045011076762KDB1000430001040371111111101602860004200322121244200319010
9prod836459045211076762KDB1000430001040371111111101602860004200322121244200321793
PRODUCTS
Cell Formulas
RangeFormula
J2:J9J2=VLOOKUP([@BIN],BINPATH!A:B,2,0)



Thank you
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
I would say yes, if you are willing to use code because I'm assuming there will be too many possibilities so conditional formatting can't be used. Someone else may know if there is another way. I'm also thinking that you could make U column values the same colour if found in column I so that both cells are orange (or whatever). However if the list of PO numbers is going to grow, you'd have to take another route or else you'll be forever editing the code - or will this be a one-off thing? If the former, I envision you colouring the cell then the code finds the value and applies the same colour to the cell where found.
How many rows in this list?

EDIT - just colouring cells means you have to go looking for them. Is there a reason why you can't just use Find on the ribbon, which will take you to the cell(s) that match?
 
Upvote 0
The PO numbers could be a range of 1 - 20 numbers.
The reason for highlighting is that the products are picked by Column J then packed by column I.
 
Upvote 0
I imagine this could be improved upon (e.g. find last row rather than choose entire I column, disable events, etc.). I went with the idea of copying the double clicked cell colour. Try setting U2 to yellow then double click U2.
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim c As Range
Dim firstAddress As String

With ActiveSheet.Range("I:I")
    Set c = .Find(Target.Value, LookIn:=xlValues)
    If Not c Is Nothing Then
        firstAddress = c.Address
        Do
            c.Interior.Color = Target.Interior.Color
            Set c = .FindNext(c)
            If c.Address = firstAddress Then
                Cancel = True
                Exit Sub
            End If
        Loop While Not c Is Nothing
    End If
End With

End Sub
 
Upvote 0
Cheers mate that seems to work.
Is there a way to put it in a macro to run, only issue is assigning a different colour to each PO number
 
Upvote 0
Not sure what you have in mind that will make it run? If that is to create what Excel users call a macro and do the same thing then that exact code won't run because there would not (might not be) Target or Cancel parameters. Can you explain what you want to do to make it run and what you mean by assigning colours to PO numbers? You'd have to do that in code at the very least. I chose copying the cell colour of the PO because it eliminates editing code to deal with colours associated with PO's. That also allows you to colour a PO cell, reuse colours, change colours, etc. and it will still find the PO and colour the cell.
 
Upvote 0
What I did is create a conditional format for column i and if it matches numbers in column U (U2:U20) then colour in chosen colour. Only problem is since I selected the whole column i it now colours in empty cells aswell because if U17 has no PO number and is empty it will fill in all empty cells in column i with that colour for that cell. :LOL:
Is there a way to only apply conditional formats within the table range?
 
Upvote 0
Include the And function in your cf formula? The logic might be like If(And(U2=something,U2<>""),result if true, result if false).
Basically saying U2 cannot be an empty string as well as it has to be equal to something else (or whatever your first part is if it's not equals).
If that's not what you meant then I'm afraid I know next to nothing about the features of Excel tables.
 
Upvote 0

Forum statistics

Threads
1,215,327
Messages
6,124,289
Members
449,149
Latest member
mwdbActuary

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