"main" is a worksheet with a "Week ending" column in it.
"expenses" is a worksheet with expense figure in column B and specific dates in column A.
I want to sum the expenses that occur on or up to 7 days before the main Week ending date.
Following the examples here: https://www.ablebits.com/office-addins-blog/2014/11/04/excel-sumif-function-formula-examples/
I came up with this
=SUMIF(expenses!A2:expenses!A1024,main!$A$2&"<="&expenses!$A$2,expenses!B2:expenses!B1024)
But it gives me zero.
EDIT
The worksheets look like this:
Main
|A |B |C |D |E |F |
|Week Ending| | | | |Expenses |
|16/11/2014 | | | | |formula goes here = should total 100|
|23/11/2014 | | | | |formula goes here = should total 25|
Expenses
|A |B |
|Date |Value|
|10/11/2014 |5.00|
|11/11/2014 |20.00|
|12/11/2014 |15.00|
|12/11/2014 |10.00|
|10/11/2014 |50.00|
|17/11/2014 |5.00|
|18/11/2014 |20.00|
This works if I just put the week ending date in the expenses sheet:
=SUMIF(expenses!A2:expenses!A1024, main!a2, expenses!b2:expenses!b1024)
But I can't change the dates because they have to match the receipts. So I tried using AND:
=SUMIF(expenses!A2:A1024, AND("<="&main!A2, ">"&main!A2-7), expenses!A2:expenses!A1024)
Still zero.
#pnuts
I tried your SUMIFS suggestion but I still get zero.
You could also try:
=SUMPRODUCT((expenses!$A$1:$A$1024>=main!$A$2-7)*(expenses!$B$1:$B$1024))
Because I think you need two conditions (one for each end of each week) I suggest SUMIFS:
=SUMIFS(Expenses!A2:A1024,Expenses!B2:B1024,"<="&Main!C2,Expenses!B2:B1024,">"&Main!C2-7)
This might be simplified if the results are in Main (eg next to the Week ending values, assumed to be in ColumnC) by not specifying that sheet.
If obliged to resort to SUMIF you might add up to the week ending date with one part of the formula and deduct up to the previous weekending date with the other part.
Related
Thanks for reading this!
Lets say we have 2 columns in this workbook called "Data":
| Column A | Column B |
| -------- | -------------- |
| Joshua | Noah |
| Daniel | Joshua |
In another workbook, I want the user to input some random name in a cell.
Below that cell, I want to be able to show him/her, in which column that name lies. E.g. if he types "Joshua", I want to be shown below:
||
|--|
|Column A|
|Column B|
I prefer using a formula, instead of VBA, as it would mess with my not-so-experienced end-user!
Notes: See below my attempt if you find it useful:
(1) I tried that using a nested IF + FILTER functions inside, but the IF returns only the first TRUE column, like this:
| |
|------|
| Column A |
| Column A |
Here is my actual formula, where I'm referring to split ranges in sheet "6", where I have 4 columns:
IF(NOT(ISERROR(FILTER('6'!B4#,ISNUMBER(SEARCH($F$4,'6'!B4#))))),'6'!$B$1,
IF(NOT(ISERROR(FILTER('6'!D4#,ISNUMBER(SEARCH($F$4,'6'!D4#))))),'6'!$D$1,
IF(NOT(ISERROR(FILTER('6'!F4#,ISNUMBER(SEARCH($F$4,'6'!F4#))))),'6'!$F$1,
IF(NOT(ISERROR(FILTER('6'!H4#,ISNUMBER(SEARCH($F$4,'6'!H4#))))),'6'!$H$1,""))))
You could use:
Formula in D2:
=FILTER(TRANSPOSE(A1:B1),MMULT(--(TRANSPOSE(A2:B3)=D1),SEQUENCE(ROWS(A2:B3),,,0)),"")
You can get the column numbers with this formula (original data on worksheet "10")
=AGGREGATE(15,6,1/('10'!A:D="Joshua")*COLUMN('10'!A:D),SEQUENCE(COUNTIF('10'!A:D,"Joshua")))
Although I suggest reducing the range references from full columns to something shorter to reduce calculation times.
With Office 365, you can convert the column number to the letter with this:
=LET(col,AGGREGATE(15,6,1/('10'!A:D="Joshua")*COLUMN('10'!A:D),SEQUENCE(COUNTIF('10'!A:D,"Joshua"))),
adr,ADDRESS(1,col,2),
"Column " & LEFT(adr,FIND("$",adr)-1))
I have a random list of numbers and a lengthy Excel sheet. I'd like to select all rows that don't have a number from the list as the value of Column B.
For example, is this is my chart...
|A |B |
|n1|0 |
|n2|1 |
|n3|3 |
|n4|4 |
|n5|7 |
|n6|8 |
|n7|10|
|n8|11|
|n9|15|
... and my range list is {0, 3, 7, 10, 11, 15}, I'd like to delete all the rows that don't meet the criteria, resulting in this new table:
|A |B |
|n1|0 |
|n3|3 |
|n5|7 |
|n7|10|
|n8|11|
|n9|15|
I'm guessing it involved the MATCH and RANGE commands somehow, but I can't for the life of me figure out how to code in Excel...
Thanks in advance!
Create a helper column using a formula like:
=ISERROR(MATCH(B2,{0,3,7,10,11,15},0))
Then you can filter on either TRUE or FALSE as necessary depending if you want to select the rows to delete or keep respectively.
I have three worksheets:
Results:
|A |F |
--------------
|J123 |56 |
|J321 |53 |
|J122 |56 |
Reference B:
|A |B |E |
--------------------
|J123 |56 |J122 |
|J421 |63 |J422 |
Reference L1:
|A |B |E |
--------------------
|J423 |66 |J422 |
|J321 |53 |J322 |
Cells in column F of the Results worksheet has this code, and works most of the time:
=IFERROR((IFERROR(INDEX('L1'!$B$2:$B$1500,MATCH($C2,'L1'!$A$2:$A$1500,0)),INDEX(B!$B$2:$B$1500,MATCH($C2,B!$A$2:$A$1500,0)))),(IFERROR(INDEX('L1'!$B$2:$B$1500,MATCH($C2,'L1'!$E$2:$E$1500,0)),INDEX(B!$B$2:$B$1500,MATCH($C2,B!$E$2:$E$1500,0)))))
The intended function is to search column A in Ref. L1 for the string in column A of the results worksheet and return the value of column B that is on the same line as the string found in Ref L1 into column F of the Results worksheet if the value is found. If it is not found then search column E and so on. If it is not found there, do the same searches in Ref. B.
It seems to work about 80% of the time and when it does not, performing the column search manually does yield a result.
Any help is appreciated.
The error was with the cell data type. I found the fix when I had searched for "vlookup unexpected #N/A". It would also apply with the INDEX/MATCH technique because they are vulnerable to the same issue of a number of a text type not being equivalent to a number of a numeric type.
The Text to columns feature under the data tab can fix it just by selecting the column -> text to data -> finish. For multiple you can find VBA macros that can pull it off.
Doing it on your lookup columns and your data source columns will ensure that the function is trying to match the same data types.
I searched through internet and came up with nothing. I have two tables. one includes work dates and the other has vacation dates. I have to find the intersected dates.
Let me give an example;
Work Table
1| A | B | C | D
2|Person | Work Start Date | work finish Date |Intersected Vacations
3|Mike | 01.08.2013 | 10.08.2013 |1 (Needed to find)
4|John | 16.08.2013 | 25.10.2013 |3 (Needed to find)
Vacations Table
1|A |B |C
2|Person |Vacation Start Date |Vacation End Date
3|Mike | 05.08.2013 | 05.08.2013
4|John | 20.09.2013 | 21.09.2013
5|John | 01.10.2013 | 01.10.2013
So, I need an excel formula to calculate the vacations between the work days.
Assuming you are counting all days within the periods, including Saturdays and Sundays you can use this "array formula" as per my screenshot below:
Formula is as follows in D3:
=SUM(IF(A$8:A$10=A3,IF(C$8:C$10>=B3,IF(B$8:B$10<=C3,IF(C$8:C$10>C3,C3,C$8:C$10)-IF(B$8:B$10<B3,B3,B$8:B$10)+1))))
confirmed with CTRL+SHIFT+ENTER and copied down to D4
This may look like overkill for your small example but I'm assuming your real data is larger - this solution can be extended as required, even for multiple unsorted vacation periods
Say I have a spreadsheet with the following, and for convenience say all of this starts from cell A1.
---------------------------------------
| Date | Item | Account |
---------------------------------------
| 01/09/2011 | Testing 1 | USD |
| 03/09/2011 | Testing 2 | USD |
| 11/09/2011 | Testing 3 | USD |
| 20/10/2011 | Testing 4 | JD |
| 22/10/2011 | Testing 5 | JD |
| 25/10/2011 | Testing 6 | USD |
| 03/11/2011 | Testing 7 | USD |
| 05/11/2011 | Testing 8 | JD |
---------------------------------------
Now, I want to run a report for a month, starting on 1/10/2011 and ending on 31/10/2011. I need to find the first row on or after the starting date, and then get every subsequent row until the end date. If I can figure out how to get the row reference for the first and end dates, then I can figure out the rows in between (obviously!).
I have only been able do these sorts of matches on exact matches ie. no idea how to do 'greater/less than' matches.
How would I go about matching on both the date and the account columns?
Needless to say, this needs to be in a formula.
=match(date(2011,10,1),a2:a9,1)+1
=match(date(2011,10,31),a2:a9,1)
First formula shows row for the first record for October, second formula for the last day. Data must be sorted in ascending order.
Use the following Array Formula for finding the Row containing the earliest date, which is equal to or greater than the date mentioned in cell C1 (in your case this is 1 October).
=MATCH(MIN(IF($A$1:$A$30>=C1,1,9999)*$A$1:$A$30),$A$1:$A$30,0)
Date list is in cells A1 to A30. Change the references as required.
Data need not be sorted in ascending or descending order.
Use the following Array Formula for finding the Row containing the latest date which is equal to or less than the date mentioned in cell D1 (in your case this is 31 October). Data need not be sorted in ascending or descending order.
=MATCH(MAX(IF($A$1:$A$30<=D1,1,0)*$A$1:$A$30),$A$1:$A$30,0)
If you want the earliest and latest dates, use the following Array Formulas.
=MIN(IF($A$1:$A$30>=C1,1,9999)*$A$1:$A$30)
=MAX(IF($A$1:$A$30<=D1,1,0)*$A$1:$A$30)
All the formulas used above are Array Formulas. To enter an array formula, use Control+Shift+Enter instead of Enter.
Vijaykumar Shetye, Goa, India
I would recommend using a pivot table for this. Look at the second link on in the "Excel Templates - Pivot Table" section on this page on the Contextures site.