Referencing cells in a different workbook using countif - excel

I'm trying to use the countif function to count how many employees complete training late. The required by date and all the completion dates are recorded on a separate workbook.
I know the usual forumula is =countif(range, criteria) and have no issues when I type an actual required by date for the criteria. The issue has to do with referencing a cell in a seperate workbook. The formula looks like this: =countif(xxxxG37:G158,>xxxxG5) with xxxx being the location of the external workbook.
The formula works just fine when I put an actual date (i.e >xxxxG5 = 11/6/17).
The issue has to deal with how I"m referencing the criteria cell.
Any help would be appreciated. Thanks! The data looks as follows:
G5 11/6/17
G37 11/2/17
G38 11/3/17
G39 11/9/17
G40 11/10/17
G41 11/1/17
G5 is the required by date. G37-G41 are the completion dates. I want to count how many of the dates are after 11/6/17.

Here is a typical syntax:
=COUNTIF([b.xlsx]Sheet1!$G$37:$G$41,">" & [b.xlsx]Sheet1!$G$35)
where the formula appears in another workbook (a.xlsx)

Related

Excel SumIF dates in another cell are from previous month

I have a table of mortgage loans in Excel. I want to sum the loan amounts(B:B) for loans whose lock dates(D:D) were in the previous month. I am trying to use the "SumIF" function to pull criteria from a different cell as below:
=SUMIF(range,"*"&A1&"*",sum_range)
But I want to pull a "date between previous month start and previous month end" range. I've used this for another function and it has worked.
D:D,">="&EOMONTH(TODAY(),-2)+1,D:D,"<"&EOMONTH(TODAY(),-1)+1
Now, I am trying to infuse the latter function into the first, something like this, but it is not returning anything. Any help would be much appreciated!
=SUMIF(Data!D:D,"*">="&EOMONTH(TODAY(),-2)+1,Data!D:D,"<"&EOMONTH(TODAY(),-1)+1)*",Data!B:B)
Use SUMIFS when you have multiple criteria, and from your explanation, it seems like you don't need the wildcard "*".
=SUMIFS(B:B,D:D,">="&EOMONTH(TODAY(),-2)+1,D:D,"<"&EOMONTH(TODAY(),-1)+1)

Indirect Function with Sheet Names

I have a list of all of the sheet names in my workbook on Sheet1 and I am trying, without success, to use the INDIRECT function to reference a cell on another sheet using said name. I am aware that this is a common question, I have looked at about 10 other questions/answers on this website in addition to others. For some reason, those solutions are not working and I am kinda losing my mind.
The sheet names are all in column A
They are named after dates (format mm-dd-yy) <- I'm assuming this is the problem?
The cell that I am trying to reference is always in O1 on every sheet in the workbook.
I have tried:
=INDIRECT(A1&"!O1")
=INDIRECT("'"A1"'&!O1")
and a few other amalgamations. Again, I have looked into so many other solutions at this point I am just left with asking for help with my situation, which is apparently unique (or more likely it is some blaring user error). Please help me before immediately removing the post.
If I have this right, the names of your sheets are dates, and you have the names listed as dates in Column A. So, they will appear as dates, but are actually Excel's background number for a date (days since 1/1/1900).
If you use the Formulas tab in the ribbon to Evaluate Formula, you should see the date pop in to your formula as a 5 digit number.
If you are not doing anything else with these dates, you could try selecting column A and formatting as text. This solved the issue in my test setup. This will still work if you are using the date for other functions, but you will have to tell Excel it's a date using DateValue()
After formatting Column A as text, I used =INDIRECT("'"&A1&"'!O1")
Try,
=indirect(text(a1, "\'mm-dd-yy\'\!\O\1"))

excel count sets of dates that date is between

Here is my data model: I have an excel sheet with each row representing a date range (an event). There is significant overlap. A2 might be 4/10/15, and B2 might be 4/12/15; while A3 might be 4/11/15 and B3 might be 4/12/15.
I am trying to get a count for each day of the year 2015 how many events occurred on that date. with my limited "for instance" I would get something like:
4/9/15 0
4/10/15 1
4/11/15 2
4/12/15 2
4/13/15 0
I have some sudo code for this if I were to just save the set as a csv and use java or something to grab each date and create an object but I find it hard to believe that excel is not capable of this on it's own.
We tried a wild number of countif and countifs statements but I am really just at a loss when it comes to excel.
I thought I was close with this:
=COUNTIF(Sheet2!A2,AND(Sheet2!A2>=(dates!B*), Sheet2!A2<=(dates!C*)))
but in order to get that to work I would need it to iterate through each row of dates and I am just not sure how to do that.
Any help is appreciated. As a backup plan I am refining my sudo-code for a possible vb excel script (never done that before) or just breaking it out into java and using the old text edit scripts I haven't had to touch since college labs.
Thank you for any help.
Your keyword is COUNTIFS
Say your criteria day is in cell Sheet2!A2 and your event ranges are in sheet Dates columns B and C; Try this formula:
=COUNTIFS(Dates!B:B, "<="&Sheet2!A2, Dates!C:C, ">="&Sheet2!A2)

EXCEL: Counting worksheets dynamically using INDIRECT

I've come across several discussions on using INDIRECT and 3D references, however none seem to address (or fix) this problem specifically.
I'm trying to count the position of a worksheet without using VBA. Each sheet represents a month, and has a standardized name (e.g. JAN-15, FEB-15, MAR-15, etc.). My idea is to find the position by counting the number of sheets between JAN-15 and the current sheet. A1 of each sheet = 1, which gets summed across the sheets using a 3D reference.
Using February as an example, I can hard code this with no problem:
=SUM('JAN-15:FEB-15'!A1)
When I do this, I get the expected result of 2. However, I want each month's sheet to dynamically generate its position without having to change the formula each time. So I tried this:
Cell named FIRSTMONTH ='JAN-15
Cell named CURRMONTH =RIGHT(CELL("FILENAME",A1),6)
N1 =CONCATENATE("'",FIRSTMONTH,":",CURRMONTH,"'!A1")
(N1 evaluates correctly as 'JAN-15:FEB-15'!A1)
When I try this formula to generate the position:
=SUM(INDIRECT(N1))
I get a #REF! error. I've also tried this variation:
=SUM(INDIRECT("N1"))
Which returns 0.
Anyone have an idea of how I can get this to work? Or is there a better way that doesn't use VBA?
-David
Assuming you won't have any gaps perhaps try counting the number of month between the first month and the current one, e.g.
=DATEDIF(FIRSTMONTH,CURRMONTH,"m")+1

Excel - Sum column if condition is met by checking other column in same table

I am trying to create spreadsheet to use in a small retail shop.
I have a workbook which contains expenses figures on a sheet and income figure on another sheet.
We can say that the common ground between the both sheets are the month.
I would like to write a function, which will only select those expenses of a specified month.
Something like -
=SUM(IF( Table4[Month]="January", Table4[Amount]))
// I want the sum of all expenses of a given table for only
// those months which are january etc.
I tried using the above, but it failed.
Actually a more refined solution is use the build-in function sumif, this function does exactly what you need, will only sum those expenses of a specified month.
example
=SUMIF(A2:A100,"=January",B2:B100)
This should work, but there is a little trick. After you enter the formula, you need to hold down Ctrl+Shift while you press Enter. When you do, you'll see that the formula bar has curly-braces around your formula. This is called an array formula.
For example, if the Months are in cells A2:A100 and the amounts are in cells B2:B100, your formula would look like {=SUM(If(A2:A100="January",B2:B100))}. You don't actually type the curly-braces though.
You could also do something like =SUM((A2:A100="January")*B2:B100). You'd still need to use the trick to get it to work correctly.
SUMIF didn't worked for me, had to use SUMIFS.
=SUMIFS(TableAmount,TableMonth,"January")
TableAmount is the table to sum the values, TableMonth the table where we search the condition and January, of course, the condition to meet.
Hope this can help someone!

Resources