Deleting entire row based on first 2 cell values in Excel - excel

I have an excel sheet with 2000 rows and 3 columns. I am looking for a solution for "deleting entire row if cell 1 and cell 2 of every row are equal. In other words,
Cell1 Cell2 Cell3
ID1 id1 val1 -delete
ID4 id1 val1 -retain
ID2 id2 val1 -delete
ID2 id1 val1 -retain
I saw a lot of answer in VBA, but I am looking for an excel solution.Thanks.

I saw a lot of answer in VBA, but I am looking for an excel solution.
I'm not sure what do you exactly mean by "excel solution", but you can add 4th column with formula:
=a2=b2
Fill the entire column with it.
Add autofilter, select TRUE in 4th column and delete all rows.
Alternatively (if you do not want the extra column), you can use conditional formatting with the same formula, set background of the cells to some unused color, and then again use autofilter to find cells with this background color.

Related

Convert an if & vlookup combination formula to arrayformula - Google Sheets

I have this formula working in Google Sheets:
=if(B3="",0,IF(ISERROR(VLOOKUP(E3,E4:E,1,FALSE)),1,0))
The logic is pretty straight forward:
if B3 is NOT NULL and there is no duplicate of E3 in range E4:E, write 1 else write 0
I tried to convert it to ARRAYFORMULA, coz it should be applied to all columns in E as and when the number of rows increase (via form submission), by doing this:
=ARRAYFORMULA(if(B3="",0,IF(ISERROR(VLOOKUP(E3:E,E4:E,1,FALSE)),1,0)))
But, it wrote 0 to all columns of E.
The reason here is that, the VLOOKUP should look in the E column range excluding the current row. I'm not sure how to achieve this.
Here is the Google Spreadsheet (please refer to Sheet2)
Can someone please correct my ARRAYFORMULA? Thank you.
You can't offset range used in ArrayFormula, so your original formula cannot be converted into ArrayFormula and remain result. But you may use this workaround:
=ArrayFormula(IFERROR(--(VLOOKUP(OFFSET(E3,,,COUNTA(A3:A)),QUERY({ROW(INDIRECT("A1:A"&COUNTA(A3:A))), OFFSET(E3,,,COUNTA(A3:A))},"select Col2, max(Col1) where Col2 <> '' group by Col2 label Col2 '', max(Col1) ''"),2,0)=ROW(INDIRECT("A1:A"&COUNTA(A3:A)))),0))
I used row function in this formula to compare it with maximum row when certain value appears.
Your sample file

Excel, returning what's not equal when comparing columns

I have a few columns for example:
a b c
1 1 0
1 1 0
0 1 0
So I can easily find out if they are equal or not (row 1 = row 2):
=and(a2=a3,b2=b3,c2=c3)
When doing this for comparing row 2 to row 3 we get FALSE, however I'd like to know a way to find out which column(s) caused the fail. In this case it would return column a.
EDIT
I guess I could check each column individually and then search for FALSE's on that row of results, but seeking something more elegant.
Here, I got one for you. This formula is for matching ROW 1 and ROW 2 of your sample data.
=IF(AND(A1=A2,B1=B2,C1=C2),"Matched","Unmatched Column: " & IF((A1=A2),"","A") & IF((B1=B2),"","B") & IF((C1=C2),"","C"))
If you want to matched more than two row, don't worry, put that formula in first row and drag the cell value to the last row. So, every row will filled with related formulas.
I think that the another way is making with excel-vba and no more way to do. If you found the other way, post it. We will vote.
Good Luck.
You can also use conditional formatting.
Highlight the range A3:C4, Choose Conditional Formatting | New Rule | Use a formula... and enter
=A2<>A3
then choose a format (e.g. fill colour) to highlight the cells that don't match.
The formula automatically changes to =A3<>A4 for the second and third rows of data, so will highlight cell A4.

Match on multiple columns

I have two Excel sheets - both have these columns:
Col 1 Col 2 Col 3
In the first sheet, I also have an additional column at the end which will be a formula to see a row with the same three values as above exist in the other sheet. If the row can be found, I want to display 'Yes', else 'No'. I've toyed with VLOOKUP's etc but no joy.
Any tips?
If your version of Excel have COUNTIFS, then that should do the trick.
If you don't have countifs formula, you can do the poor man's version (what I did with Excel 2003 way back when) and combine the columns. So in Col4, put formula
=Col1 & Col2 & Col3
Then you can place your Yes/No If formula in Col 5. Suppose the three data points are named cells (this, that, the). The formula would look like:
=IF(Col4 = this & that & the), "Yes", "No")

Advanced Filter criteria does not work for more than one criterion

I am trying to filter a column in Excel (2003). The column is populated with "filenames". I want to filter certain types of files using Excel's "Advanced Filters".
The filename column (B) exists in sheet1, and the filter list in sheet2 column B.
sheet1 sheet2
column B column B
1 Heading 1 Heading
2 file.doc 2 <>*.doc
3 file.html 3 <>*.pdf
4 file.pdf 4 <>*.mp3
5 ... 5 ...
This is what I have found after many hours of search on the Internet. The problem is that this works for one entry, but not all. I.e. if I mark the entire column B in sheet1 and use column B1:B2 in sheet2 as the area criteria then Excel filters out all files that end with ".doc". But if I use column B1:B4 in sheet2 then nothing happens.
What I have tried so far:
"<>*.ext"
="<>*.ext"
OR(.ext,.ext2)
OR(".ext",".ext2")
=OR(...)
<>(...)
ISERROR(SEARCH())
and many many more...
What am I doing wrong?
Since this is an OR filter, you need to put the criteria in the same row. It should look like the following:
Sheet2
Column B Column C
1 Heading Heading
2 <>*.doc <>*.pdf
Here's an excellent post on advanced filters: http://searchengineland.com/advanced-filters-excels-amazing-alternative-to-regex-143680.
"AutoFilter allows you to filter using a maximum of two criteria." and "When you want to specify an AND operation you must place the conditions in separate columns." both from bettersolutions.com.
I think the best that can be managed this way is to choose two of your sheet2 selections in adjacent columns (say B2 & C2) of sheet2 and then use the range sheet2!$B$1:$C$2 as the criteria.
Maybe though to get what you want use a PivotTable just of sheet1 ColumnB and filter there.

Referencing current cell for compare across sheets

I'm trying to compare binary values between two sheets in Excel. Here's a quick snapshot of what the data might look like for row 1, columns A-D on the two sheets.
A B C D
1 1 1 1 1 <--- Sheet 1
A B C D
1 1 1 0 0 <--- Sheet 2
What I would like to do is Conditionally Format sheet 2. I'm only concerned about the cells where the values are not the same, so in the example above cells C1 and D1 on Sheet 2 do not match the values on Sheet 1, so I want to either change the font or background. At this point I don't care. If I were just comparing these 4 cells I could do this easily enough. But I've actually got 160 rows and about 1000 columns of binary data, so I don't want to condition each cell individually. What I can't figure out is how to conditionally format the entire sheet using a formula that references the current cell vs the current cell on the other sheet.
For excel 2010:
Select the area on sheet 2 you want to compare
Select conditional formatting under the "home" ribbon, then "new rule"
Select "use a formula to determine which cells to format"
Type the following, but replace "A1" with the top left cell in your selection range, and replace the sheet names with your sheet names
=IF(Sheet1!A1=Sheet2!A1,FALSE,TRUE)
Select your desired format
Hit "OK" on both dialogs
In general, you could use a comparison utility like BeyondCompare. Ensure each sheet is saved into its own file, then throw them at the utility.

Resources