Formula to match two values between two worksheets - excel

I have two spreadsheets...Days and Visits. The first spreadsheet (Days) contains Name/Date. The second spreadsheet (Visits) also contains Name/Date. I am trying to get a formula that if the name and date appear on both spreadsheets that a value of "Yes" is returned on the Visits spreadsheet.
This is the formula I'm using but the Yes/No column an say "No" but I can clearly see some names should say Yes.
{=IFERROR(INDEX('Physician Visits'!$A$2:$F$800,MATCH(1,IF('Physician Visits'!$A$2:$F$800=A2,IF('Physician Visits'!$A$2:$F$800=C2,1)),0)),"No")}
Any help would be most appreciated!

Because of the way you have written your formula you are trying to find to different values in the same cell. The two IF's iterate together and since the ranges in the criteria are the same the cell in which you are looking are the same. And one cell cannot equal two different values at the same time.
There is a better way, use COUNTIFS()
=IF(COUNTIFS('Physician Visits'!$A:$A,A2,'Physician Visits'!$F:$F,C2),"YES","NO")
This assumes your comparing column A to Column A and Column C to Column F. If different ensure your are comparing the correct columns to one another.

Related

Excel - General formula to reference a cell in a certain column with varying row

In my worksheet in column F I have a list of names, that may appear or disappear according to other inputs in the spreadsheet. I want the cells in the columns G:AZ to remain blank if the corresponding cell (i.e. same row) in column F is also blank. Because I have thousands of cells to which I need to apply this, I'm using Pullover's Macro Creator to add this small change to all the formulas inside the cells really quickly, so I can do entire columns in seconds. In column J, for example, I've been applying this formula:
=IF(COUNTBLANK(INDIRECT("RC[-4]",0))=1,"",[this part changes and doesn't matter])
You can see that I need to change that "-4" to different numbers according to the column I'm working on. But I have so many columns that it's still going to be a pain to change that hundreds of times.
My question: Is there a formula I can use in the COUNTBLANK function that can reference the corresponding cell in column F without needing any changes in different columns and different rows? And since the INDIRECT formula is so volatile (I still don't know what that means, but I guess it's bad), is there a solution that doesn't use this formula?

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).

select the same rows from a column between two spreadsheets or two columns

I have thousands of entries for the same site names taken between different days. However not all row labels are identical. I just want to select all row labels that are shared among both spreadsheets based on the names contained in column A for example and copy them to a new sheet. Filtering and selecting wont work, theres thousands and different entries between the two. I just want to delete entries that are not shared among both spreadsheets.
I looked through other forums using vlookup but I am not sure i understand the syntax:
e.g. i looked at this forum: Matching two columns from two spreadsheets and grabbing data from one of the spreadsheets
it proposed this solution: =index(sheet2!B1:B3;match(sheet1!G1;sheet2!A1:A3;0)). So this solution join row from 2nd sheet to row first sheet. If column G 1st sheet and column A 2nd sheet are the same then you can use this to match. Place formula in column H 1st sheet. With this formula you will fetch data from column B 2nd sheet to column H 1st sheet.
I dont think this is the case since the positions of similar row values in both columns differ. I just want to know what labels are shared among both and delete entries that dont share those names
example of output
Yes vlookup is the key because if you lookup something in spreadsheet1:colA to see if it is in spreadsheet2:colA if it is not present you will get a null value. Then you can filter out these nulls to get only the list of rows which share the column A value in spreadsheet2. You will also need to repeat this in spreadsheet2.
For context, assuming the image you posted covers cells A1:C6, and your highlighted cells are A4:C5 then:
In sheet1 cell D3 put =VLOOKUP(A3, Sheet2!A:A, 1,0) and copy down for the rest of column D, and in sheet2 cell D3: =VLOOKUP(A3, Sheet1!A:A, 1,0)
IF the vlookup finds a match, this will give the exact same value in columnD which is present in both spreadsheets, otherwise it will give #N/A. Then you can filter those out.
(By the way the syntax for the sheet name depends on whether you have spaces in the name so Sheet1!A:A but 'Sheet 1'!A:A, I usually get these by highlighting them so excel does the work of naming the worksheet).
A side note, I would drag both worksheets into one file, you certainly can perform vlookups between different files, but this then relies on the exact file path so if you ever move either file, the vlookups will break and give you errors. I only ever vlookup within the same file.

Sum values based on first occurrence of other column using excel formula with Subtotal function

I already viewed the posting about summing values based on first occurrence in another cell but I would like to add a complication and nestle in a subtotal function. Basically I would like to sum values in the Score column based upon the first and only instance of a value in Color with subtotal filtering via one formula.
There are two formulas that somewhat give me the two components required but I'm limited in my formulaic abilities to combine these:
Sum values based on first occurrence in another column:
=SUMPRODUCT(B2:B8/COUNTIF(A2:A8,A2:A8))
Subtotal with sumproduct:
=SUMPRODUCT(B2:B8,SUBTOTAL(9,OFFSET(C2:C8,ROW(C2:C8)-MIN(ROW(C2:C8)),0,1)))
Unfiltered Table
Filtered Table
Any ideas?
Many thanks in advance
You can combine both formulas as below:
=SUMPRODUCT(B2:B8/COUNTIF(A2:A8,A2:A8),SUBTOTAL(3,OFFSET(A2:A8,ROW(A2:A8)-MIN(ROW(A2:A8)),0,1)))
The first part of the above formula is from your SUMPRODUCT formula so it is easy to understand, the second part of the formula should be using 3 - COUNT for the SUBTOTAL formula so it will return 1 for values showing in the filtered range and 0 for values that are not.
Let me know if you have any questions. Cheers :)

How can I search across Excel sheets?

I want to transfer data automatically from 2 sheets to one single combining one. That means I have 2 different export sheets (called 'Te_open' and 'Te_closed') that contain both the columns "Problem" (in different positions, can vary always). I have one sheet, that represents an overview of the data from the two other export sheets. So when I have for example the value "Te1" in the cell A2 of my overview sheet, I want Excel to search in the two export sheets the value "Te1" and give back the value in the same row as "Te1" but of the column "Problem", so that I can fill the cell B2 where I want to have the Problem type. So I thought I might need the "MATCH" formula, to let excel know I want to search the column with the headline "Problem" in the export sheets, to fill the column "Problem" in my overview sheet.
The problem that I see is that I have to search TWO sheets and I don't know in which one the "Pm1" will appear. Furthermore I don't know in which column of the sheet "Problem" will appear.
Can you please help me? I would preferably like to solve the problem with a formula, not a macro. Thank you very much in advance.
Kind regards,
question
To find the index of the first column in one of your sheets that is headed 'Problem', you can use (e.g.):
=MATCH("Problem",Te_open!$1:$1,0)
Let's assume we place that formula in a cell somewhere and name the cell open_col. To find a value in column A of Te_open and return the corresponding value from the 'Problem' column, you can then use:
=VLOOKUP(A2,Te_open!$A$2:$Z$999,open_col)
Note that you'll have to define the search range to include the largest range that your data on Te_open could occupy. If the search value is found this will return the corresponding value from the 'Problem' column, otherwise it'll return #N/A. So if you've also set up a cell called closed_col to get the column index for the Te_closed sheet, you can do:
=IF(ISNA(VLOOKUP(A2,Te_open!$A$2:$Z$999,open_col)),VLOOKUP(A2,Te_closed!$A$2:$Z$999,closed_col),VLOOKUP(A2,Te_open!$A$2:$Z$999,open_col)
That gets the result from the correct column of Te_open if the search value was found there, otherwise it gets the result from the correct column of Te_closed. If neither sheet contains the search value it'll return #N/A.

Resources