Find duplicate cells in multiple excel sheets - excel

I have an excel sheet with multiple spreadsheets. There are columns 'firstname' and 'lastname' of about 1000 rows in each of the spreadsheets. I have recorded a macro which shows me the duplicate rows having in the format 'firstname lastname'.
=IF(SUMPRODUCT(($B$2:$B$1000=B2)*1,($C$2:$C$1000=C2)*1)>1,"Duplicates","No duplicates")
The above formula can find duplicate rows in one sheet. How do I tweak the formula so that it can match with the other sheets as well. A formula or VBA will also do.

You can fool Excel into accepting a 3D range reference as a parameter of COUNTIFS with INDIRECT and array processing courtesy of a SUMPRODUCT wrapper. With the names of the worksheets to be processed in Z2:Z4 then this will count duplicates across the worksheets for the first and last names in columns B & C.
=SUMPRODUCT(COUNTIFS(INDIRECT("'"&$Z$2:$Z$4&"'!B:B"),B2,INDIRECT("'"&$Z$2:$Z$4&"'!C:C"),C2))
You should be able to incorporate that standard formula into your IF() statement for duplicate recognition.
Please note that INDIRECT is considered a volatile function that recalculates with any change in the workbook. Depending upon the extent of your data it is likely that you will experience some calculation lag.
      

Related

VBA code to pull cell values from a list of closed workbooks

In a worksheet I have a column of references to cells in unique workbooks, e.g. in cell A1:
='Filepath[Workbook1.xlsm]Sheet1'!$A$1
In other columns I want to pull values from other cells in other sheets of each of those same workbooks, e.g. 'Filepath[Workbook1.xlsm]Sheet2'!$B$2
However, I do not want to have to manually copy/paste the filenames into the new columns and then in each of them change the formula to Sheet2'!$B$2
So what I did was write an INDIRECT formula, e.g. =INDIRECT(MID(FORMULATEXT(A1),2,FIND("]",FORMULATEXT(A1))-1)&"Sheet2'!$B$2")
However, as I've found from other posts, there is a limitation of the INDIRECT function that the file being referenced must be open, otherwise it REFs out.
Is there a way in VBA (or just Excel) to circumvent this?

Filter rows from multiple sheets in Excel without VBA

I have an Excel file with three sheets, with data in each sheet organised in the same manner - headers are the same.
Without using VBA (as macros are not allowed by my organisation's security policy), I would like to find all rows from all sheets that meet a simple column value check and show those rows in a separate sheet.
For example:
Sheet2 has,
Sheet3 has,
Sheet4 has,
I want sheet1 to have all rows from sheets 2-4 with Header7 column value = "Hit",
What I have achieved so far is, using an array formula I could get all the "hits" from one sheet in sheet1.
The formula for A2 to A6 in sheet1 is as below, with the ROW(1:1) changing to ROW(2,2) and so on from A3 onwards. Columns B to G use the same formula with range adjusted accordingly.
{=IFERROR(INDEX(Sheet4!$A$2:$A$6,SMALL(IF(Sheet4!$G$2:$G$6="Hit",ROW(Sheet4!$A$2:$A$6)),ROW(1:1))-1,1),"")}
What this does is a bit complicated. In short, it creates an array of either FALSE or row numbers based on Hit and then finds the index of the non-false values.
Now, I can solve the last part of combining the idea to include all sheets in two ways (I think).
Have another temporary sheet (sheet5) with all rows from sheets 2 to 4. Update my formula in sheet1 to use sheet5 instead of 4.
Have the range Sheet4!A2:A6 etc changed to include a 3D reference like Sheet2:Sheet4!A2:A6. But this doesn't work, and the documentation for 3D reference doesn't mention that it works with array functions.
PS: I don't have Power Query, which seemed to have an easy way to create a new sheet with all rows from multiple sheets, because I work on a Mac (MS Excel for Mac).

Lookup data based on a date that falls between two dates

I have to sheets within a workbook. On sheet 1 I there is a date that is the LOOKUP criteria(cell B9). I need to look in Sheet 2 and if the falls between the dates in Columns A and C...if so, then lookup the info in columns D thru K and populate the cells (E10 thru E16) on sheet 1.
I currently used the following formula in cell E10 in sheet 1...
=LOOKUP(2,1/((DATEVALUE($B$9)>='AUSSIE Wkly'!$A$3:$A$500)*(DATEVALUE($B$9)<='AUSSIE Wkly'!$C$3:$C$500))
But nothing comes up as you can see. Please help.
In your example, you want to retrieve values in row 4.
In Sheet1, cells E10, E11 you would use
=INDEX(Sheet2!$D$3:$D$500,SUMPRODUCT((Sheet2!$A$3:$A$500<=Sheet1!B9)*(Sheet1!B9<=Sheet2!$C$3:$C$500)*(ROW(Sheet2!$A$3:$A$500)-ROW(Sheet2!$A$3))))
=INDEX(Sheet2!$E$3:$E$500,SUMPRODUCT((Sheet2!$A$3:$A$500<=Sheet1!B9)*(Sheet1!B9<=Sheet2!$C$3:$C$500)*(ROW(Sheet2!$A$3:$A$500)-ROW(Sheet2!$A$3))))
You could put together similar formulas for the other cells.
I take the opportunity to stress the power of SUMPRODUCT, quite often more flexible and comprehensive than: 1) Array formulas, 2) Lookups, 3) COUNTIFS, 4) SUMIFS.
I am leaving here for those interested a few links showing that.
Better than COUNTIFS
COUNTIFS with ISNUMBER and multiple criteria
Have COUNTIFS ignore all blank cells (= empty cells and cells containing "")
Multiple lookups
Searching an excel with two search words (multiple lookup) using vba macro
Multiple-column based lookups in Excel
Finding rows with multiple values in the columns
On two questions related to yours
Excel: Counting how many rows fall within a time period
How to calculate results and plot data depending on results of a specific column in excel?
(and you are welcome here, which shows I am actually "fond of" SUMPRODUCT).

How to insert column of cells from one sheet to a single cell of another sheet in OpenOffice?

I have a sheet 'MODELS' with columns of data, each column varies in how many cells (rows). I'm wanting to paste a column from this sheet into another sheet 'COMBINED' into a single cell.
For my first cell in COMBINED, I tried using formula:
='MODELS'.A1:A15
However, this resulted in only displaying the data in cell (MODELS) A1 instead of the entire range (A1:A15).
Is there a formula to accomplish this?
I don't think Excel/OpenOffice has a built-in function to do this. You could write a user-defined function (UDF) or a Macro using VBA to accomplish this. Here's a thread which you might find useful:
http://www.mrexcel.com/forum/excel-questions/16401-concatenate-range-cells.html

How to input two arrays in VLOOKUP?

I have a worksheet in Excel 2013 with two sheets: Sheet 1 and Sheet 2. I am applying a formula in both the sheets in the same column (G). The data is in more than 100,000 rows that's why I can't put it in one sheet only.
The problem is that I want to use VLOOKUP in both sheets in a way that the function looks up in both sheets in the same columns (arrays) i.e. A and B columns in sheet 1 and sheet 2 and get the value from column B i.e. column 2 within VLOOKUP function.
How can I add reference to the other sheet?
I doubt a complete solution is possible with VLOOKUP because, for instance, the corresponding ColumnB values may differ even where a ColumnA value is the same on both sheets. So without VBA (or possibly merging your sheets) you may have to compromise, so I offer only a partial solution, based on Excel 2007.
This 'looks up' in the 'other' sheet and only defaults to the 'same' sheet where the first attempt is unsuccessful. It uses INDEX and MATCH because likely quicker than VLOOKUP for high volumes. The formula I have applied for Sheet1 (in G1 and to be copied down) is:
=IFERROR(INDEX(Sheet2!B$1:B$6,MATCH(E1,TwoArray,0)),INDEX(B$1:B$7,MATCH(E1,OneArray,0)))
where the OneArray and TwoArray are named ranges for parts of ColumnA for the two sheets and the link values are expected in ColumnE (the formula in Sheet2 is similar):

Resources