Edit IF statement using filenames in a column - excel

I have a column with filenames:
Excel1.xlsx
Excel2.xlsx
Excel3.xlsx
etc
etc
etc
and I also have this IF statement:
=IF('[MainExcel.xlsx]Data'!$C$4='[Excel1.xlsx]Data'!$C$4,IF('[MainExcel.xlsx]Data'!$E$4='[Excel1.xlsx]Data'!$E$4,7,IF('[Excel1.xlsx]Data'!$C$4>'[Excel1.xlsx]Data'!$E$4,5,0)))
So I am trying to comparate an Excel Worksheet (Data) from all these files (Excel1, Excel2, Excel3, etc) with a main Excel (MainExcel)
Any way of doing this without having to change the IF statement one by one in every row?
Thanks in advanced!

Use a combination of concatenate and indirect.
Since I don't know the full layout of your sheet I won't get too in depth but, for example
=IF(INDIRECT(CONATENATE("[",A1,"]Data'!$C$4"))=4,TRUE,FALSE)
where A1 is the cell that has the name of the other excel file.

You can use the INDIRECT function to build references to other workbooks, using cell references.
As an example, that you can build upon.
Assume:
Excel1.xlsx -> Excel3.xlsx respectively have the values 1, 2, 3 in
cell A1 on Sheet1,
All workbooks are open (or else we would have to add path information
that the file names were in column A
The following entries in column B would pull the appropriate values from the referenced workbooks.
=INDIRECT("'["&A1&"]Sheet1'!A1")

Just using what others have said, assuming that the cell containing the first workbook name "Excel1.xlsx" is in cell A1, then try:
=IF(Data!$C$4=INDIRECT("["&A1&"]Data!$C$4"),IF(Data!$E$4=INDIRECT("["&A1&"]Data!$E$4"),7,IF(INDIRECT("["&A1&"]Data!$C$4")>INDIRECT("["&A1&"]Data!$E$4"),5,0)))
Also, I note that it appears that the case in which the first comparison is false is not covered under your subsequent values (your function just returns the value "false").

Related

Multiple Cells Check Without VBA?

So, trying to explain what I need here is my two sheets on the same workbook, Sheet Example:
I need to make a formula for each cell that checks Sheet A "Num_Doc_Ini" and "Num_Doc_Fin" against Sheet B "CHV_CTE_REF", calculates the total after adding up the "VL_DOC" numbers on Sheet B, and finally Checks with "correct" or "Incorrect" after comparing the result to the Sheet A "VL_DOC".
So for example, the second line of Sheet A. I need to make so that check see's the NUM_DOC_INI and FIN so "101 - 102" checks those numbers on Sheet B "CHV_CTE_REF", adds up the "VL_DOC" so in this example 4,159.86 + 4,585.1 that equals = 8,744.96, and then matches it with the "VL_DOC" on Sheet A displaying in this case the text "Correct" and If it does not match displays "Incorrect".
Some lines have few docs to reach like "106 - 108" but there are some that have 10 or more to read and sum up the values, because of that I'm really breaking my mind trying to come up with something.
Is that even possible? I can think of a few ways to use VBA for this but I'm trying to do this all with Cells Formula and because of that I am kinda lost, any help would be appreciated thanks!
Edit:
I'm using excel 2016 atm.
So here is a file for the workbook: https://mega.nz/file/LgVCBbjT#xJnf2HbHd6wdRSNPY7wXSssKv2jZ1-pMsOuKcePlulQ
And the explanation with colors:
I need on the Red Cell a formula to check the numbers of the Blue ones on sheet 1, find them on Sheet 2 (blue cells), add up the VL_DOC (Green ones) on sheet 2, and check them up against the values on Sheet 1 Orange cells (VL_DOC), then print out Correct or incorrect based on the match of the values.
From what I can see in the link, you can use something like the below if you have the newest version of excel (where row ranges and column references are left to your specific case because we can't see them):
=IF(SUM(FILTER(SheetB!$VL_DOC,
(SheetB!$CHV_CTE_REF=SheetA!J2)+(SheetB!$CHV_CTE_REF=SheetA!I2)+...))=N2,
"Correct", "Incorrect")
Then add however many other conditions within the FILTER function you need. For example:
REQUESTED EDIT: If you don't have the newest version of excel, you can just repeatedly use VLOOKUP or INDEX/MATCH however many times is necessary. For example:
=IF(SUM(
VLOOKUP($I2, SheetB!$CHV_CTE_REF, 2,),
VLOOKUP($J2, SheetB!$CHV_CTE_REF, 2,),
...)=$N2,
"Correct", "Incorrect")
SUM, INDIRECT, ADDRESS, MATCH
Note that INDIRECT is a volatile function.
In cell K2 of Sheet 1 of the example workbook, you can use the following formula:
=IFERROR(IF(SUM(INDIRECT(ADDRESS(MATCH(H2,Tabela1[NUM_DOC],0)+1,COLUMN(Tabela1[VL_DOC]),1,1,"Sheet 2")&":"&ADDRESS(MATCH(I2,Tabela1[NUM_DOC],0)+1,COLUMN(Tabela1[VL_DOC]),1,1),TRUE))=J2,"Correct","Incorrect"),"")

Returning data from across multiple worksheets in Excel

How do you create formulas that will return the totals, averages, counts, min, max, etc from different worksheets? The columns (that exist) are consistent in their header information, but may or may not be different from one sheet to the next, column number wise. Let's say I have 7 tabs of data, some or all of them may contain a column heading of beans, for example, but the column numbers may or may not be consistent across all tabs, where present. Their actual locations within the worksheet are completely dynamic.
My spreadsheet has several tabs of raw data that I want to compare against in a summary/report sheet. I'm sure this can be done but I am afraid it is a little too far beyond the capability of this old brain.
I've thought about and toyed with a bunch of formulas using indirect, index, match and just can't figure it out. Your help would be most appreciated. Thanks
Here's a possible function only solution. The final result will look like:
We will use four(4) primary functions:
ADDRESS
INDIRECT
MATCH
LEFT
Note: Just follow the link if you have question on how to use these functions
The formula: This is in cell C4 Above
=AVERAGE(
INDIRECT(
"'"& C$3 & "'!" &
LEFT(ADDRESS(1,MATCH($E$2,INDIRECT("'"&C$3&"'!1:1"),0),4,1),1)
& ":" &
LEFT(ADDRESS(1,MATCH($E$2,INDIRECT("'"&C$3&"'!1:1"),0),4,1),1)
)
)
Edit1: To handle the comment below for headers beyond 26, change this
LEFT(ADDRESS(1,MATCH($E$2,INDIRECT("'"&C$3&"'!1:1"),0),4,1),1)
to this:
SUBSTITUTE(ADDRESS(1,MATCH($E$2,INDIRECT("'"&C$3&"'!1:1"),0),4,1),"1","")
Basically what is does is:
Find where the header Bean is located using MATCH function. To do that, you will have to incorporate the use of INDIRECT since your sheet name is dynamic (in this example, your sheet name is in C3 - Data1). (I assumed all your headers are in 1st row, I use 1:1 in there). Note: In this example, Bean is in column H of Data1 sheet
MATCH($E$2,INDIRECT("'"&C$3&"'!1:1"),0) <~~ returns 8
After finding where it is, we need to get the entire column address so we can apply counting and summing functions (e.g. SUM,COUNT,AVERAGE etc...). To do that we use the ADDRESS function combined with LEFT to get the column letter.
LEFT(ADDRESS(1,MATCH($E$2,INDIRECT("'"&C$3&"'!1:1"),0),4,1),1) <~~ returns H
Then we just repeat that formula and connect it with : to get H:H
Now that we have the column address, we simply connect it again with the sheet name and apply the final INDIRECT function plus the counting and/or summing function of your choice.
Sample formula of Total in C5:
Sample formula of Max in C6:
Finally, all you have to do is copy the formula across all columns with sheet name. Just add sheet names beside the last one and copy formula. That's it. I hope this is close to what you want and I hope that all the functions I used are available in Excel 2000.

Concatenating File Path Excel

Lets say I have columns with dates on them.
The file path is something like this:
='U:\Report\[Date 042516.xls]Joe Smoe'!$C81
Where the '042516' is variable to each column. !$C81 is variable to each row in the original document.
How do I do this and pull up the respective numbers from the reports and dates?
I think I understand - so you have a column with numbers (042516,042517,042518, etc), and you want the formula to update that part of the path, as you drag down?
If your 042516 is in C1, you can use this:
=INDIRECT("'U:\Report\[Date "&C1&".xls]Joe Smoe'!$C81")
(Note the workbook being referenced, Date 042516.xls, must be open for Indirect to work.)

How to tell if a cell exists on another Google Sheet

I have 12 sheets in one Google Sheets document labeled for each month (January - December). On each sheet column A contains a project number, e.g. "6091".
I'm trying to find a function that will check all of the other sheets to see if there are duplicate cells in the "project number" column of other sheets.
So: "Do any of the cells in column A, match any of the cells in column A on other sheets".
Is there a quick way to do this?
The formula =arrayformula(iferror(match(A2:A, AnotherSheet!A2:A, 0))) checks each value in A2:A of the present sheet for being in A2:A of AnotherSheet. If it's there, it returns the position in AnotherSheet, otherwise the output is empty (the error #N/A is suppressed by iferror).
You can use the above for each of the sheets separately. Alternatively, if you are not interested in the positions and just want to know which entries from A2:A are found elsewhere, then add the results for each sheet:
=arrayformula(iferror(match(A2:A, AnotherSheet!A2:A, 0)) + iferror(match(A2:A, ThirdSheet!A2:A, 0)))
The output is 0 is there is no match, and a nonzero number if there is.
You may try using this to find the number of duplicates:
=counta('JAN'!A:A,'FEB'!A:A)-countA(unique({'JAN'!A:A;'FEB'!A:A})
Where A:A is your column for the data you want to check and the respective files.
This formula counts the total number of data you have, minus the unique data, therefore giving you the total number of duplicates in your dataset.
This formula gives you an overview of the total number of duplicates, however, it doesn't show which cell is a duplicate.
Alternatively, you can add a checker column and input the following formula to check if that specific cell is a duplicate.
=match(cell to check,{range 1;range 2;...range 12})
Alternatively, you may use this formula to find the exact duplicates between the ranges, however this formula does not search within the range itself for duplicates.
=arrayformula(filter(range to check,(countif(arrayformula({Range 1;range 2}),{range to check}))>1))
Personally I think that the last option would be the best as it gives you the exact data to correct.
I am still new to this so hope this helps:)
This formula should work for numerical values:
=COUNT(QUERY({March!A:A;April!A:A},"where Col1="&A2))
If you are searching for text values it would be
=COUNTA(QUERY({March!A:A;April!A:A},"where Col1='"&A2&"'"))
Unfortunately the QUERY function does not work within an arrayformula so you would need to copy the formula down the column. You can add in extra sheets into the { } array as required, separated by a semi-colon
Edit: actually, borrowing from #sandwich, this version should work without the need to copy the formula down the column:
=arrayformula(iferror(match(A2:A,{March!A:A;April!A:A},0)))

How do I search across sheets in Excel

I want to transfer data automatically from 2 sheets to one single combining one. That means I have 2 different exports that contain both the columns "Problem". I have one sheet, that represents an overview of the data. So when I have for example the value "A333" in A1 of my overview sheet, I want Excel to search in the two other export sheets the value "A333" and give back the value in the same row as "A333" but of the column "Problem" not "A".
The problem that I see is that I have to search TWO sheets and I don't know in which one the "A333" 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.
1) write a formula (VLOOKUUP() for example) that looks for the value in the first sheet
2) write a formula that looks for the value in the second sheet
3)since VLOOKUP returns an ERROR if a value is not found you can combine the formulas together using IFERROR(). for example: =IFERROR(VLOOKUP(ref_cell,sheet1_range,2,0),VLOOKUP(ref_cell,sheet2_range,2,0))
EDIT:
It looks like you did not provide all the pertinent information in your question!
I suggested VLOOKUP(), but this will only work if you know which COLUMN the value you are looking for will appear in, but you said this is not the case...
using you comments I therefore assume the following:
the two test sheets are called "test1" and "test2"
The reference value we are looking for is in cell A5 on the main sheet, cell D1 on the sheet contains "Problem" (text)
The reference value may appear anywhere (I limit here to range A1:J100) on test1 or test2, but ONLY ONCE
The column "Product" on test1 and test2 may appear in different columns, but it will always have a heading "Product" in row 3 (test1!A3:J3 and test2!A3:J3)
see below of screenshot of the answer (column C shows result, column D shows the underlying formula)
If required use the information provided to create a single-cell formula (because Stack Overflow is not a we-write-the-answer-for-you service)
Following the scheme:
and add the formula:
E3 -> =CONCATENATE(IFERROR(VLOOKUP(D3;$A$12:$B$15;2;FALSE);"");IFERROR(VLOOKUP(D3;$A$3:$B$6;2;FALSE);""))
and autocomplete ...

Resources