SUMIF for multiple spreadsheets with text conditional - excel

I have an Excel book with around 100 spreadsheets within the book. Each spreadsheet is an application of certain products. The very last spreadsheet is a total tally for the year for each product we use. The SUMIF formula I am using is:
=SUMIF('Jan 1:Dec 31'!B5:B14,"Name of product",'Jan 1:Dec 31'!D5:D14)
So when the Name of the product is used in B5:B14 in all spreadsheets from first (Jan 1) to last (Dec 31) I want to sum its value from the D5:D14 cells in all spreadsheets from first (Jan 1) to last (Dec 31).
The problem is that I just end up getting a #VALUE error. I have also tried inputting the formula by holding Ctrl+Shift. Nothing seems to work.

You could use the indirect formula and have Jan 1 in cell A1, and then in B1 have formula:
= sumif(indirect(A1&"!B5:B14"),"Name of product",indirect(A1&"!D5:D14"))
Then you'd put Jan 2 in cell B1 and copy the sumif formula down.
Note that this assumes structure is consistent on each tab and that number of rows is consistent on each tab as well (or you can make the bottom of the range an arbitrarily high number like row 50,000)

Related

Excel Count Number of Items if Same Year Across Multiple Worksheet Specific Cell

I have about 50 worksheets, each Worksheet contains specific cell (G11) in date format (dd-mmm-yy); other 5 worksheets used for other purpose.
What I need to do, first, to check cell G11 in the 50 worksheets match to current year and current month, then, count total number of G11 that meets current year and current month across all 50 worksheets. Finally, the counted number will be reflected in separate worksheet.
I had tried SUMPRODUCT or 3-D Reference, but I got return with #VALUE!. A2 is current mmm-yy; Sheet Name in 4 digit numbering:
=SUMPRODUCT(--(TEXT(INDIRECT("'"&Table[Sheet Name]&"'!$G$11"),"mmm-yy")=TEXT(A2,"mmm-yy")))
You could do:
=SUM(--(TEXT(N(INDIRECT("'"&Table[Sheet Name]&"'!$G$11")),"mmm-yy")=TEXT(A2,"mmm-yy")))
or
=SUM(--(TEXT(N(INDIRECT(ADDRESS(11,7,,,Table[Sheet Name]))),"mmm-yy")=TEXT(A2,"mmm-yy")))
If you have lower than Excel 2016, you have to do CTRL+SHIFT+ENTER to enter this formula.

excel formula help on counting unique dates between specified dates

I am writing an excel formula for work. I have an updating sheet that counts for the month's output for each person. I want to keep track of how many days they have worked. by counting the unique dates they input into the sheet but only between the month dates placed on the master lookup form. ex
the month is 01/01/2019 - 01/01/ 2019 column a contains dates entered by employee cell e2 contains months beginning cell d2 contains months end found by eomonth. I want to search dates in column a for dates between e2 - d2 and output in e3 number of days worked.
=if(COUNTIFs(J3:J,J3:J&"",J3:J,">="&N2,J3:J,"<="&O2) = 0 ,"no days worked",SUMPRODUCT((J3:J<>"")/COUNTIFs(J3:J,J3:J&"",J3:J,">="&N2,J3:J,"<="&O2)))
is what I have so far. it keeps giving me the second part of sumproduct cannot be zero. but that formula is giving me 4 if used by itself based on the data set I am giving it. so I'm not sure where I am going wrong.
This is what I came up with.
=SUM(--(FREQUENCY(OFFSET(INDEX(Dates,IFERROR(MATCH(Dstart,Dates,0),MATCH(Dstart,Dates,1)+1)),0,0,COUNTIFS(Dates,">=" & Dstart, Dates,"<=" & Dend)),OFFSET(INDEX(Dates,IFERROR(MATCH(Dstart,Dates,0),MATCH(Dstart,Dates,1)+1)),0,0,COUNTIFS(Dates,">=" & Dstart, Dates,"<=" & Dend)))>0))
In a largely unsuccessful bid to make this formula more readable a created named ranges as follows.
Dstart = your D2
Dend = your E2
Dates = your J:J
You may replace the names with the addresses. However, I do not recommend the use of J:J because these 3 characters represent 1.4 million cells referenced repeatedly. If your data is of smaller size I recommend to stick with a named range for them and limit the size of that range somewhat.
Note that the formula is bloated because it counts unique values only. Its action, in a nutshell, is to find the first cell to match Dstart, then establish the last cell by counting how many entries there are and, finally, count unique items within that range.

Countifs Indirect with Column increment

I'm working on a workbook, containing 33 sheets, 31 sheets for daily tasks.
I wanted to show daily productivity in about 15 columns each day,I used Indirect with countifs but when I copy formula to next 15th cell it never goes to the right reference ..
=(COUNTIFS(INDIRECT("'"&SL$6&"'!J:J"),"B2",INDIRECT("'"&$SL6&"'!$L:$L"),$C7))
This formula counts In specific day (sheet) in J:J "Paid"("B2") while also it counts the person who sold items "Name"("C7")
this formula works perfect but...
in SL6 my sheet reference lays, for example, SL6:Sheet1 SM6:Sheet2
I want this formula in next 15th cell while it goes toTA6 which is Sheet16's reference, it should go to SM6, I know if I drag this formula into very next cell it will produce the right result but my formula will be staying every 15th cell till 31 sheets.. please I avoid VBA

Conditional sum with merged cells using Sumiif()

Scenario is 2 worksheets, Sheet1 and Sheet2.
Sheet1 config:
Sheet2 Config:
The problem:
The customer wants to input the daily amounts of bananas in Sheet2 (C:C) and have the totals automatically add in Sheet1 for the week number. The problem I'm facing with this, I believe is the merged cells. I was successful when I removed the merged cells and added the week number to all the cells with this formula ( =SUMIF(A:A,E3,'Sheet2!C:C) ) But the customer would prefer to keep the merged cells, and with that it only returns the first value of that week. Am I missing something simple here? Can't seem to wrap my head around this.
Merged cells are a bad idea for several reasons and should be avoided.
That does not mean that you can't achieve the look your client wants. You can fill the numbers into all the unmerged cells and then use conditional formatting to hide six of the seven numbers. In the screenshot below, column A has a conditional format with this formula
=MOD((ROW()+2)/7,1)
The format applied is custom number format ;;; (or use white font on white background). Adjust the formula if your data starts on a different row.
Note that the formula bar clearly shows that the selected cell has the value 26.
This is what I found:
=SUM(IF(LOOKUP(ROW(Sheet2!$A$2:$A$15),ROW(Sheet2!$A$2:$A$15)/(Sheet2!$A$2:$A$15<>""),Sheet2!$A$2:$A$15)=A2,Sheet2!$C$2:$C$15))
This is an array formula. Enter into sheet 1 C2. Hit Ctrl Shift Enter. Then copy down.
From my point of view, the important aspect to this specific layout is that a week has 7 days and you are listing every day in the week. A merged cell is identified by the top-left cell in the merged area. Looking for 26 returns A2 and looking for 27 returns A9. If you reference column C with those row numbers and extend the range to 7 rows then you can sum for the matching week.
In G2 (per the image supplied),
'volatile OFFSET function
=SUM(OFFSET(INDEX(C:C, MATCH(E2, A:A, 0)), 0, 0, 7, 1))
'non-volatile INDEX function
=SUM(INDEX(C:C, MATCH(E2, A:A, 0)):INDEX(C:C, MATCH(E2, A:A, 0)+6))
The dates in either table are inconsequential beyond visual reference.

Count number of occurrences by month

I am creating a spreadsheet with all my data on one sheet and metrics on the other.
On sheet 1 in cells A2:A50 I have the dates in this format (4/5/13). On sheet 2 in cell E5 I have April and I want it to total the number of PO's created in F5.
How can I do this?
I have tried using
=COUNTIF('2013'!$A$2:$A$50,'2013 Metrics'!E5).
I have a feeling that since my range is in 4/5/13 format and my criteria is April that won't work.
I was able to use this formula for total spend by month:
=SUM(IF(MONTH('2013'!$A$2:$A$19)=4,'2013'!$D$2:$D$19,0))
but not luck with how many PO's by month.
Use a pivot table. You can manually refresh a pivot table's data source by right-clicking on it and clicking refresh. Otherwise you can set up a worksheet_change macro - or just a refresh button. Pivot Table tutorial is here: http://chandoo.org/wp/2009/08/19/excel-pivot-tables-tutorial/
1) Create a Month column from your Date column (e.g. =TEXT(B2,"MMM") )
2) Create a Year column from your Date column (e.g. =TEXT(B2,"YYYY") )
3) Add a Count column, with "1" for each value
4) Create a Pivot table with the fields, Count, Month and Year
5) Drag the Year and Month fields into Row Labels. Ensure that Year is above month so your Pivot table first groups by year, then by month
6) Drag the Count field into Values to create a Count of Count
There are better tutorials I'm sure just google/bing "pivot table tutorial".
For anyone finding this post through Google (as I did) here's the correct formula for cell F5 in the above example:
=SUMPRODUCT((MONTH(Sheet1!$A$1:$A$50)=MONTH(DATEVALUE(E5&" 1")))*(Sheet1!$A$1:$A$50<>""))
Formula assumes a list of dates in Sheet1!A1:A50 and a month name or abbr ("April" or "Apr") in cell E5.
Make column B in sheet1 the dates but where the day of the month is always the first day of the month, e.g. in B2 put =DATE(YEAR(A2),MONTH(A2),1). Then make E5 on sheet 2 contain the first date of the month you need, e.g. Date(2013,4,1). After that, putting in F5 COUNTIF(Sheet1!B2:B50, E5) will give you the count for the month specified in E5.
I would add another column on the data sheet with equation =month(A2), then run the countif on that column... If you still wanted to use text month('APRIL'), you would need a lookup table to reference the name to the month number. Otherwise, just use 4 instead of April on your metric sheet.
use count instead of sum in your original formula u will get your result
Original One
=SUM(IF(MONTH('2013'!$A$2:$A$19)=4,'2013'!$D$2:$D$19,0))
Modified One
=COUNT(IF(MONTH('2013'!$A$2:$A$19)=4,'2013'!$D$2:$D$19,0))
AND USE ctrl+shift+enter TO EXECUTE
Recommend you use FREQUENCY rather than using COUNTIF.
In your front sheet; enter 01/04/2014 into E5, 01/05/2014 into E6 etc.
Select the range of adjacent cells you want to populate. Enter:
=FREQUENCY(2013!!$A$2:$A$50,'2013 Metrics'!E5:EN)
(where N is the final row reference in your range)
Hit Ctrl + Shift + Enter
Sooooo, I had this same question. here's my answer: COUNTIFS(sheet1!$A:$A,">="&D1,sheet1!$A:$A,"<="&D2)
you don't need to specify A2:A50, unless there are dates beyond row 50 that you wish to exclude. this is cleaner in the sense that you don't have to go back and adjust the rows as more PO data comes in on sheet1.
also, the reference to D1 and D2 are start and end dates (respectively) for each month. On sheet2, you could have a hidden column that translates April to 4/1/2014, May into 5/1/2014, etc. THen, D1 would reference the cell that contains 4/1/2014, and D2 would reference the cell that contains 5/1/2014.
if you want to sum, it works the same way, except that the first argument is the sum array (column or row) and then the rest of the ranges/arrays and arguments are the same as the countifs formula.
btw-this works in excel AND google sheets. cheers

Resources