Highlight Rows in Sheet1 that match values in Sheet2 - excel

It's been a long time since I've done anything advanced in Excel. I have Excel 2010. I've watch many videos and tried some tutorials that do sort of what I'm looking for, but I'm just missing something.
This is what I'm trying to accomplish... I have a list of about 50 SKUs in Sheet2. I have a complete list of 200 Products in Sheet1.
SHEET1:
ColA are SKUs
ColB is Desc
ColC is Price
SHEET2:
ColA are SKUs
I need a formula or Macro that will look at all SKUs in Sheet2, then find any matches in Sheet1 ColA, then highlight the rows where there is a match.
I would really appreciate any help you can provide, even if it's just a link to an exact example. Thank you!

If you just want to mark matching rows you can do something easy. This will return matching SKUs, or #N/A if no match:
=VLOOKUP(A2,Sheet2!$A:$A,1,FALSE)
If you really want highlighting you could use the helper formula above and set up conditional formatting (CF) over the range. The CF formula will be something like
=NOT(ISNA($D2)) (assuming you put the VLOOKUPs in column D)
There is another way to do CF that uses no helper formula. First you need to set up a named range on Sheet2 A:A. I'll call it SKUs in this example.
Then a CF formula like this will tag matching rows:
=MATCH($A2,SKUs,0)>0
Edit: I am assuming the data (and CF range if you use that) starts in row 2, allowing for a header in row 1.

This may be a little late, but I figured I would still add my 2 cents. I use the following formula to do something similar...
=IFERROR(IF(VLOOKUP(B1,Sheet2!$A:$A,1,FALSE)>0,"Y","N"),"N")
Basically I just have a column of Y or N for if that item is also on "Sheet2" and this is the formula that decides whether it is a Y or N.

Just use your VLOOKUP() along with IFERROR() in a conditional format formula.
Select the range you would like to apply conditional formatting then do Home -> Conditional Formatting (in 2007) then "Apply a formula".
Then you'll want to apply a formula more or less like this one:
=IF(IFERROR(VLOOKUP($A2, Sheet2!$D$2:$D$4, 1, 0)), 0, 1)
Just adapt the ranges to your needs. I tested this to work on 2007.

You can use conditional formatting in Excel 2010 to achieve what you want to do.
There are 2 ways to do this. The first one works only with the ranges in one sheet whereas the second one lets you work across sheets.
Assuming you can copy and paste both the ranges in one worksheet, you can select both ranges using Control key. After selecting the ranges, Go to Home->Conditional Formatting->Highlight Cell Rules->Duplicate Values. Now Select Duplicate in the dialog box and it should highlight the names in Range 1 that are appearing in Range 2 (your original SKU list).
If you can't copy and paste the second range into the same worksheet, then you have to use a formula with conditional formatting. Select the used range in ColA in sheet1, Go to Home->Conditional Formatting->New Rule. Now Select the Rule Type 'Use a formula to determine which cells to format'. Now type the formula like this (this formula assumes that your cursor is in A1 when you apply invoke the dialog)
=COUNTIF(Sheet2!$A$1:$A$3,Sheet1!A1)
That should highlight in Sheet1 all the items found in Sheet2. Edit the above formula to include the correct range for your situation and use a dynamic range if you know how to do it.
I have used approach 1 countless times and I have just tested approach 2 with a sample and it works. If they don't work for you, please let me know and I can help you further.

Related

Skipping blank cells with an Index/Match formula

I've got several databases containing 100/1,000's of rows where the information is presented something like this:
I need to get all the information relevant to each company onto one row; I'm not able to do a simple Sort & Filter as nearly every company has a different level of detail, so information ends up in the wrong rows. Looks like the best option is an Index/Match formula, but my current formula
=INDEX(Sheet1!B:B,MATCH(Sheet2!$A2,Sheet1!$A:$A,0)
returns zeros for any result where the first Index/Match result is blank:
How can I write the formula so that it skips the blank cells? I'd prefer not to have to use VBA however any advice would be very much appreciated.
Alternatively,
Because match is always the return the first value it found.
So in cell G2,
=INDEX(Sheet1!G:G,MATCH(Sheet2!$A2,Sheet1!$A:$A,0)+COUNTA($G$1:G$1)-1)
Or by matching the header to offset the cells.
You can just wrap your existing formula in an IF function:
=IF(Sheet2!$A2<>"",INDEX(Sheet1!B:B,MATCH(Sheet2!$A2,Sheet1!$A:$A,0),"")
I will normally use a "Go To Special" function for this.
Say for example for the sample data below.
I will put in the first formula '=IF(B2<>"",C3,"")'. Copy that cell (Ctrl+C), then select cells from C2 to C7 and use the 'Go to special' to select Blank cells only under Home tab, in Editing > Find & Select > Go To Special. Simply just Paste the formula to all the blank cells by Ctrl+V. You will get all the information in one row on the first row for each companies.
Hope this helps.
Step1:
Create a pivot table with your data and in the pivot options select 0 for the blank cells.Copy all the fields into row area...
Step2:
Apply conditional formatting as shown in the below image to remove (blank) cells.
Note: This is not a robust solution but worked for me.

COUNTIFS with different-sized ranges / INDEX-MATCH and COUNTIF

Headline: I need to make a summary table that, for each row, looks to another sheet, finds the corresponding row based on a criteria (name), and counts the number of instances of a certain value ("P") across several columns.
Specifics:
I am making a summary "cover sheet" for an excel doc that summarizes information from other sheets. So, Sheet1 looks like this:
....and I want to fill in the "Attendance" column (B:B) on this sheet. I want it to do this by counting the number of P's in another sheet. Sheet2 looks like this:
(note that names are not in the same order as on Sheet1)
Desired outcome (which I hand-entered here):
IMPORTANTLY/Annoyingly: Because of some annoying rules & regulations, I'm not allowed to simply add a helper column to Sheet2 (E:E) (=countif(B2:D2,"P") that I'd then simply import in (=INDEX(Sheet2!E:E, MATCH(A2, Sheet2!A:A, 0)).
I've tried making a hybrid INDEX-COUNTIF & a hybrid COUNTIF-MATCH solution, but to no avail.
My best guess was using COUNTIFS, but when I do COUNTIFS(Sheet2!A:A, A2, Sheet2!B:E,"P")) I get an error message that says, "Array arguments to COUNTIFS are of different size."
Any help would be appreciated!
=SUMPRODUCT((Sheet2!$A$2:$A$8=A2)*(Sheet2!$B$2:$D$8="P"))
Place the above formula in Sheet1, cell B2 and copy down.

With Excel Conditional Formatting - Want to Highlight Cells in a range that match any from another range of cells

Sheet One has 5 cells in a row with numbers. (A2:F2)
Sheet Two also has 5 cells in a row with numbers. (A3:F3)
I'd like to highlight sheet one's cells yellow every time that sheet two has a matching number entered. (There will be more rows of data added to each sheet, but I am using the first row only, to keep it simple.
It works with creating a CF equals to, but I need something that applies to a range of data, from a range of data to make this less tedious. Thank you for any tips!
I am using conditional formatting. I have tried Vlookup, Match, and Countif, but I am new to this type of formatting.
(Sheet two's numbers can be placed in a list (column), instead of a row, if that matters)
I'd suggest using COUNTIF:
=COUNTIF(Sheet2!$A:$F,A2)>0
Snapshot of Sheet1 and the Conditional Formatting:
Snapshot of Sheet2:

Insert Formula through Data Validation in excel

In Data validation list I defined formulas: ,=1,5+($B$1/$B$2),=2+($B$1/$B$2)*2,=2,7+($B$1/$B$2)*3 ..... and works well for me because I can see all formulas in dropdown list as they are to choose the appropriate one.
But I prefer to define them in a named range since number of formulas are around 20. Unfortunately I can see only the results instead of formula origins in dropdown list when I define as named range so makes me choose the suitable one impossible.
I wonder whether to see the formulas itself when I defined in named range. Thanks in advance.
It won't work. To see the formulas, you'd have to format them as text in the source cells, but then selecting them from the dropdown won't actually evaluate the formula.
Something like this may work.
A. Enter the list of the formulas you want to use in a range of your worksheet, one formula per cell, without the equals signs. An example list of formulas:
1
5+($B$1/$B$2)
2+($B$1/$B$2)*2
7+($B$1/$B$2)*3
B. Create the cell with Data Validation to select from the formula list
C. Use MATCH and CHOOSE to select which formula you want to use for calculations:
=CHOOSE(MATCH(Formula,FormulaList,0),1,5+($B$1/$B$2),2+($B$1/$B$2)*2,7+($B$1/$B$2)*3)
Here Formula and `FormulaList are placeholders (or named ranges) for the cell that has the chosen formula and the list of formulas, respectively.
Hope that helps

Excel contains filter with more than 2 values

Does anyone know how I can quickly hide/remove all rows in sheet1 that contain any of the rows info from sheet2?
It would need to contains filter as it wouldn't be an exact match.
For example
Sheet1:
http://www.google.com/something/else
http://www.yahoo.com/whatever
www.microsoft.com/hahha
Sheet2:
google.com
So the end result would be the first line in Sheet1 would be hidden
In practice I'm working with thousands of rows in sheet1 and around in Sheet2.
To clarify, I'm essentially trying to do a contains filter with more than 2 values - the default filter only allows 2 values.
Also I am working with Excel for Mac 2011.
You can do this quickly with a simple helper column without a large range loop.
For simplicity as a sample:
Assuming your Sheet 1 list was in A1:A1000
your Sheet 2 partial list was in C1:C5 (on the same sheet for the picture below)
then in range B1:B1000 enter this array formula,
=MAX(IF(ISERROR(FIND($C$1:$C$5,A1)),0,1))=1
(Enter as an array formula by pressing Ctrl+Shift+Enter)
Then AutoFilter the TRUErows (which flag any matches) and hide them
As i was reading the solution posted by #brettdj I think it should work for your problem.
From your comment it seems you have an empty cell problem when using his solution. Are you sure you replaced the $C$1 : $c$5 with the right values?
In your case you should first refer to the right sheet (Sheet2 if you didn't rename it) then the right column (assuming you have it in column A of sheet2).
You should write =MAX(IF(ISERROR(FIND(sheet2!$A$1:$A$5,sheet1!A1)),0,1))=1.

Resources