Sumproduct in excel using external data source - excel

I am trying to calculate some data in a excel using external excel file. My formula is like;
=SUMPRODUCT(--('[Stock Register.xlsx]Stock Code 1'!$E$3:$E$500="Issued to Sanitary Syndicate"),'[Stock Register.xlsx]Stock Code 1'!$C$3:$C$500)
This works fine for me. But I need the sheet (Stock Code 1) being changed automatically when dragging or pasting on the next rows.
I am using it a new workbook using external data source (Stock Register.xlsx). Stock Register consisting of 570 sheets and for each sheets I need to display results in that New Workbook in cell (C1) using above formula and drag it to cell (C70).

You can add two columns before the SUMPRODUCT.
First column, say this is in column B, will need to have CONCATENATE to the external spreadsheet that you want to link to. For example:
=CONCATENATE("[Stock Register.xlsx]Stock Code",ROW(A1),"!$E$3:$E$500")
This should give you [Stock Register.xlsx]Stock Code 1!$E$3:$E$500.
Same thing for the second column that you want for $C$3:$C$500 so you can get [Stock Register.xlsx]Stock Code 1!$C$3:$C$500.
Then the third column, say this is in column D, will be the SUMPRODUCT formula that with INDIRECT. And here you go:
=SUMPRODUCT(--(INDIRECT(B1)="Issued to Sanitary Syndicate"),INDIRECT(C1))
Hope this helps.
P.S. One thing I noticed when combining all three into one column, the formula wouldn't work. Someone probably can come up a better way but to have a reference address sit next to the result may benefit you to debug down the road. Just a thought.
UPDATED:
Okay, I was able to recreate what I described below. Maybe it is easier to show you in screenshots:
See I created three sheets in Stock Register.xlsx file, Stock Code 1 sheet looks like below that values under column C and descriptions under column E.
And another spreadsheet called Results.xlsx. Column B has a formula of =CONCATENATE("'[Stock Register.xlsx]Stock Code ",ROW(A1),"'!$E$3:$E$500").
In this picture, Stock Code 2 sheet looks like below.
Column C in Results.xlsx spreadsheet has a formula of =CONCATENATE("'[Stock Register.xlsx]Stock Code ",ROW(A1),"'!$C$3:$C$500").
In this picture, Stock Code 3 sheet looks like below.
Column D in Results.xlsx spreadsheet has a formula of =SUMPRODUCT(--(INDIRECT(B1)="Issued to Sanitary Syndicate"),INDIRECT(C1)).
Try again and let me know.

Related

Copy data from another cell if criteria is met

I have quite a problem. In the excel spreadsheets, I have a lot of data entered into one main spreadsheet and some of the into another.
In the main Spreadsheet (Sheet1), I have column L, that has tons of entries of unique numbers. Also, I have a column Q that stores another data for a lot of entries into the sheet.
In another sheet (Sheet2), I might have some of the entries that can be the same with the column L in the Sheet1, and they are stored in column D, on Sheet2. So, if those two sheets entries matches (L:L in Sheet1 with D:D in Sheet2), I want to have the Q entry from Sheet1 into my, lets say N column at Sheet2. If they don't match, blank would be ok.
I've been searching the solution for quite a time, found some on Microsoft official website, but I haven't been able to apply it.
This one was the closest solution I could find, but, since I'm newbie with Excel, I haven't been able to implement it correctly.
Edit:
To Illustrate a bit, here is exactly what I am looking for:
Lets say:
Sheet1
L2=115457; Q2=2148446
L3=381493; Q3=Blank
L4=121214; Q4=484846
L5=151515; Q5=Blank
Sheet2
D143=381493; N143=(need input from Q2)
D523=121214; N523=(need input from Q4)
D968=151515; N968=(Blank)
Thanks in advance.

I'd like to click on data in one cell and be transferred to another sheet that contains that initial cell data but with a different dataset?

Situation: Excel book with 3 sheets. First sheet is ProductSummary. 2nd: BatchSummary. 3rd BatchDetail.
ProductSummary has general product data that is common in the other sheets. Column C in ProductSummary is titled ProductMaterialCode.
We'd like to be able to click on a cell in Column C, and after clicking we are transferred to the 2nd sheet (BatchSummary). On this sheet, we will see all columns that relate to the date point that was clicked on in Column C. Column C on both sheets are both ProductMaterialCode. A similar process will occur in the 2nd sheet to get to the 3rd sheet.
I assume that I want to use hyperlinks, but I don't understand how to get them to work for this project.
Thank you for the help!

Excel Formula to Lookup multiple columns

I tried reading other questions on this matter, and everything is very specific to that person so it got pretty confusing...
Anyways, I was looking for a way to use VLOOKUP or Index Match to do the following (I've been trying but I keep running into errors or weird...long....formulas...):
I have 2 excel Sheets. One excel sheet has something like this:
(This is incomplete. I haven't put in prices yet, but I'm working on the formatting and formulas foremost. Just pretend there are prices in those empty cells :) )
The second excel sheet is this:
In the 2nd Sheet, F Column, I was trying to get a formula to match Sheet2ColumnE with Sheet1 Columns A,F,K,P,U & Z and return [depending on whether cell D is B or S] the single or bulk price for the specific item.
I've used the Index Match formula before, but it got tricky when I had to index multiple columns and match multiple columns. Is there a simple way to get this going? Or will I be looping IFs?
Thanks for assistance.
Here is the workbook. Or a sample of it...
Test.xml

Find and Compare Two Columns Excel (With Screenshots)

I have a spreadsheet that will occasionally get new data that I don't know the contents of, I just have to add it to the spreadsheet. Some of the new data is just updating rows that are already in the spreadsheet, and other data is adding new rows. I'm looking for a way to add a column that will tell me if something has changed in the row when I compare the old spreadsheet to the new one.
The sheets have one column that will always have a unique value among all the rows, so I can use that to match rows if the sheets aren't sorted the same way. Here are some screenshots to show what I'm trying to do:
Old Spreadsheet:
New Spreadsheet:
The only solution I can think of is a large nested IF formula that compares each column one by one, something like:
=IF(Old!B2=New!B2,IF(Old!C2=New!C2,"NO","YES"),"YES")
The problem with that is that it gets very hard to look at since my actual data is using 33 columns (not including this "Changed?" column) and new columns could be added in the future.
I'm not very technical with Excel, nor have I ever used VBA, so I apologize in advance if there is a simple/obvious solution that I'm missing.
Thanks in advance for your help.
Using your example, in the 'New' sheet cell D2 and copied down:
=IF(COUNTIF(Old!A:A,A2)=0,"YES",IF(SUMPRODUCT(COUNTIF(INDEX(Old!A:AG,MATCH(A2,Old!A:A,0),0),LEFT(A2:AG2,254)&"*"))=SUMPRODUCT(COUNTIF(A2:AG2,LEFT(A2:AG2,254)&"*")),"NO","YES"))
vlookup would also work well for this problem.
in D2, the formula would be:
=IF(AND(VLOOKUP(A2,Old!A:C,2,FALSE)=B2,VLOOKUP(A2,Old!A:C,3,FALSE)=C2),"NO","YES")
The column numbers (2 and 3) are the columns that correspond to the data you are trying to match, using the ID column.
It's possible to find the appropriate column using MATCH if the column names you have match the column names in the old sheet
This would make the formula look more complex, but Excel would adjust the Old!A:C reference if more columns are inserted.
The formula would look like this to match against column names
=IF(AND(VLOOKUP(A2,Old!A:C,MATCH($B$1,Old!$1:$1,0),FALSE)=B2,VLOOKUP(A2,Old!A:C,MATCH($C$1,Old!$1:$1,0),FALSE)=C2),"NO","YES")
The difference between this and the last one is the use of MATCH($B$1,Old!$1:$1,0) to find the column (using $s to anchor the lookup values)
In this case, specialized software for Excel compare is better.
My company use this software. Check it out.
http://www.suntrap-systems.com/ExcelDiff/
http://www.youtube.com/watch?v=QQgnWr_RT-8

How do I get my formula to always reference to the last sheet?

I currently have 2 worksheets in my excel file.
The first sheet is known as the Summary page, which displays an summary result of the second sheet.
The second sheet is known as the raw data. An example would be a column named Fruits.
Apple
Apple
Apple
Banana
Banana
Pear
In the first sheet, I would have a formula that counts the number of time the respective fruits appear and the result will be displayed in different cells.
=COUNTIF(Fruits!A2:A7,"Apple")
=COUNTIF(Fruits!A2:A7,"Banana")
What I wanna do is, is it possible for me to program the formula such that everytime I add a new sheet of raw data (3rd sheet), the statistics on the first sheet is able to reference to the latest sheet to get the information.
(Assuming that the positioning of the data and all are the same as the second sheet.)
What I have done so far is to come out with a function GETLASTWSNAME() which is able to always retrieve the name of the last worksheet. but it seems kinda impossible for me to nest the function within the countif formula itself.
=COUNTIF((GETLASTWSNAME())!A2:A7,"Apple)
The above formula is how i want my formula to work, but sadly excel does not allow me to do that.
Any comments would be appreciated. Thanks!
You can use the XLM/Range Name workaround for this and not VBA if you prefer
Define a range name, wshNames to hold the array of sheet names
=RIGHT(GET.WORKBOOK(1),LEN(GET.WORKBOOK(1))-FIND("]",GET.WORKBOOK(1)))
Uses David Hager's technique
Use this Excel formula to extract the last sheet name from the array of sheet names
=INDEX(wshNames,COUNTA(wshNames)+RAND()*0)
This formula says look at all the sheets, then return the last (using the COUNTA). The RAND()*0) portion ensures that the formula is volatile and updates when Excel does
If you do use VBA you will need to ensure your GETLASTWSNAME function is volatile, i.e. it gets updated when changes occur.
=COUNTIF(INDIRECT(GETLASTWSNAME() & "!A2:A7"),"Apple")
In Excel with spill function and the new Sequence() you can list all your sheet names with the same technique just from one cell! First to last or last to first, your choice. With Transpose you get a column header for each sheet (Obs volatile).
After defining the named formula wshNames as told by Tomalak ( thanks for the tip ) I used:
=INDEX(wshNames;COUNTA(wshNames)+1-SEQUENCE(COUNTA(wshNames);1;COUNTA(wshNames);-1))
my Excel is using ";" as a separator, you may have to change the semicolons with a comma
Rolf H

Resources