Excel - Create dynamic sum formula range - excel

I am currently using the following formula
=SUM(INDIRECT("'Net "&($A$2)&" "&RIGHT($A48,2)&"'!C4:C21"))
That works out perfectly, but I'm trying to make the range portion of it (C4:C21) dynamic.
The $A$2 that the formula is referencing is something that someone types in and currently says "May". The $A48 that the formula is referencing is simply pulling the last 2 digits of the year.
These are the pieces of the file
There are a total of 6 tabs that are significant. There are 4 tabs that total up prior years sales for a particular month. So I have Net May 11, Net May 10, Net May 09, Net May 08. These are the tabs that the Indirect formula is finding.
The last 2 tabs includes the one where this formula exist in (Net May 12) and the tab that the range will need to be based off of (Cust May 12). In the Cust May 12 tab Column A is the day, column B the day of the Week, and column C is where we have our sales data. Someone goes in every day and types in the sales for the day. So as an example I currently have sales data from 5/1/2012 until 5/18/2012. Everything from 5/19/2012 - 5/31/2012 in column C is blank. The sales data that currently exist are in C4:C21, with C22:C34 being blank. Because I am comparing prior years sales to this years sales they must be comparable, which is why the formula only uses C4:C21 for all of the prior years sales.
I have tried a few things including a CountA and some offsets to try and help me out, but I have been unable to find a solution to making the range dynamic for all of my prior years sales formulas. I need the formula to simply increment to something like C4:C22 for all of the prior years when someone types in the sales data for the next day in the Cust May 12 tab.

Your question is not completely clear, but it sounds like you want something like:
=SUM(OFFSET(INDIRECT("'Net "&($A$2)&" "&RIGHT($A48,2)&"'!C4:C4"),0,0,COUNTA('Cust May 12'!$C$4:$C$34)))
However, you might want to consider restructuring your data to store it in only one worksheet, say with columns like Year, Month, Day, and Sales. Then, questions like, "What were 2011's month to date sales for May," are easier to answer (particularly with the SUMIFS function added in Excel 2007) like this:
=SUMIFS(<Sales column>,<Year column>,2011,<Month column>,"May",<Date column>,"<="&DAY(NOW()))

Related

Trying to correctly duplicate formulas keeping same cell range but adjusting date ranges

I'm trying to help someone with an Excel spreadsheet of sales figures. I hope this explanation is clear. She has a worksheet for each category of items she sells, such as clothing, shoes, furniture, &c. Each worksheet has a column, G, for Date Sold, and the data is in Date format.
On a summary worksheet, she wants to aggregate and analyze the data, and one thing she was doing manually was counting the number of sales of each category for each month (sometimes zero).
I helped her write a formula to pull the count from the clothing worksheet, for the month of March 2019 into a cell on the summary worksheet:
=COUNTIF($CLOTHING.G3:G502;">2/2019")-COUNTIF($CLOTHING.G3:G502;">=4/2019")
This correctly yields 5. Cool. But that is just one month, and we need twelve for each year, for multiple years, and we have six categories. So we'd rather not hard-code each formula every time we need a count.
When we tried to copy the formula into cells below (for April, May, etc), hoping it would adjust the dates, it wrongly adjusted the cell range to G4:G503. The cell range shouldn't change; the months should advance, but they did not change.
We've been trying different suggestions we found online, such as naming the range G3:G502 but it didn't like that. We got an error.
We both (obviously) have a limited knowledge of Excel. Please let me know what we're doing wrong OR if there is a better way to approach this, and how to do it step by step. Please ask any questions if my explanation is not clear.
Using your formula I would adjust it as follows:
=COUNTIF($CLOTHING.G$3:G$502;">="&DATE(2019;row(1:1);1))-COUNTIF($CLOTHING.G$3:G$502;">"&EOMONTH(DATE(2019;row(1:1);1),0))
Note the addition of the $ to the cell reference. This keeps either the column or row from change when a cell is copied.
Row(1:1) will return 1 in the first cell it it entered into and as it is copied down will increase by 1. Therefore it is important not to copied it down more than 12 rows from its initial entry point.
Note the year in the date is hard coded. Alternatively the year could be placed be place in a cell and a reference to that cell could be used in place of the hard coded year. That way in subsequent years, you would just change the value in the cell instead of changing your value in the hard coded formula.
Note this solution assumes January for the first cell and months following sequentially to December for the 12th cell.
I my system is configured to use , as separators instead of ; so it is possible I may have made a mistake with those in my edits.
Alternatively you could look at COUNTIFS. It is similar to COUNTIF but requires all entries to be TRUE for an entry to be counted.
=COUNTIFS($CLOTHING.G$3:G$502;">="&DATE(2019;row(1:1);1);$CLOTHING.G$3:G$502;">"&EOMONTH(DATE(2019;row(1:1);1),0))

VLOOKUP & COUNTIF

I'm looking for some help on trying to combine functions.
I think I need VLOOKUP & COUNTIF.
I have Sheet 1 with a list of clients, column A, I then have 12 other tabs Jan-Dec same table format on each, client listed in column C.
On sheet 1, I want to count from every month tab how many times listed (invoices sent)
Not every client in the list will appear on the month invoice tabs , others more than once.
Please see screenshot attached
Any advice would be appreciated.
Thank you
Amy
You only need CountIf. Just reference the client on Sheet 1:-
=countif(January!C3:C100, Sheet1!A3). Copy this down to reference the client on each row.
You could also consider the following for a better working and easier spreadsheet:-
-Define ranges and reference those instead
-Copy all your monthly data with the year into one sheet. Have a column for month and year then just autofilter to get the month you want - using countif to also reference the month and year if you just want a particular one in question
You'll find it easier to grown your spreadsheet and build formulae if your data is tidy and less dispersed.
Hope this helps,
Phil

How do I sum a total number of occurrences of a ID number with a specific month and year in Excel

I have a Excel Master sheet where I am looking to query other sheets within the workbook. What I am trying to do is see How many occurrences of an ID for a Project in a column occur within a month, e.g. how many times does the ID 1367 occur in November. My dates are in the format of e.g 13/11/18 and this cannot be changed as I am just creating a report against a workbook I do not own.
The relevant columns I need are formatted like so:
Project: Project ID: Date:
a 123 1/01/2018
a 123 2/01/2019
a 123 3/01/2018
a 123
This is my SUMIFS function:
=SUMIF(PPlanner!$D:$D,Dashboard!$B$6,PPlanner!X:X)
This works by itself. My problem is trying to get the ID total for a specific month.
It returns the number of occurrences the ID occurs against a project all together but not against the month specifically. I have tried adding syntax to specify
the month but I am getting errors such as "too many arguments".
I recently answered a question that was very similar :
Excel - Take Average of Monthly Data
I think this would answer your question as well, but you have to use COUNTIFS instead of AVERAGEIFS
As for presentation, I would make a separate list of the months you want to include, and put the formula next to it, instead of the formula next to the actual list of data (as in the other question). As for how to write/input the month, you can put it any way you want, as long as it is a valid date in Excel. With the cell formatting you then can show it as month and year only. This is just to say that a text input JANUARY 2018 does not work (in a normal cell, eg. a cell that you did not format as text, when you type that into the cell, Excel recognizes this as a date, and will actually put 1/1/2018).
Oh, and using a Pivot table would work as well, the other answer on the question referenced above also explains how to do that.
In some cases, how Excel handles dates is very convenient.
For you, the date format doesn't matter. It is simply a number counting days with 0 being December 31st, 1899.
13/11/18 the date is the integer 43417 in-cell value. Excel interprets this as a both date and time together. The whole numbers are the days while the decimals are the time of day as a fraction of the day. 43417.5 would be noon.
So you may use COUNTIFS to help here.
=COUNTIFS(PPlanner!$X:$X, 1367, PPlanner!$D:$D, ">"&43404, PPlanner!$D:$D, "<"&43435)
This is going to look at sheet PPlanner column X and count how many instances of 1367 occur after the last day of October and before the first day of December. There are other ways to accomplish this, but it allows you to count within any date range you want.

Return value of last non blank cell in 3D range

I'm working on a workbook that tracks monthly numbers, and also provides a yearly and quarterly summary for those months. The workbook has a Fiscal Year sheet, four quarterly sheets (named Q1-Q4), and 12 sheets for the months (Jul, Aug, Sep, Oct, etc). All of sheets in this workbook look identical.
Completing most of the Fiscal Year sheet is fairly simple, just use the formula =SUM(Jul:Jun!B3), which looks at all 12 monthly sheets and sums cell "B3". No problems there.
However, we have a backlog section that shows how far behind we are. For this number on the Fiscal Year sheet, I just want the number from the latest month of data. Since it's not a cumulative sum of all the months before, it's causing me issues.
I need a formula that will find the last non-blank cell in those 12 monthly sheets (they are in fiscal year order), and return just that cells value. The range for that formula would be Jul:Jun!B17. So if March is the last months worth of data, and the backlog number for march is 56, I want 56 to show on my Fiscal Year sheet.
I tried using
=LOOKUP(2,1/('Jul:Jun'!B17<>""),B17)
But it becomes this
=LOOKUP(2,1/('Jul:[June]June'!B17<>""),B17)
And returns a #REF! error. Any ideas?
Thanks!
If I interpret your question correctly, then the following Array formula will give you what you seek: =INDEX(A1:A16,MAX(IF(ISNUMBER(A1:A16),ROW(A1:A16),""))).This can be put in A17 for July and copied across the row to L17 for June.
Ahhh,I see.The following formula is a bit cumbersome, but solves what you are trying to accomplish.I would imagine that using VBA would be more direct and simpler, but in your example of effort you used formulas so I take it that you prefer a formulaic answer :
=CHOOSE(MAX(IF(Sheet1!B17>0,1,0),IF(Sheet2!B17>0,2,0),IF(Sheet3!B17>0,3,0),IF(Sheet4!B17>0,4,0),IF(Sheet5!B17>0,5,0),IF(Sheet6!B17>0,6,0),IF(Sheet7!B17>0,7,0),IF(Sheet8!B17>0,8,0),IF(Sheet9!B17>0,9,0),IF(Sheet10!B17>0,10,0),IF(Sheet11!B17>0,11,0),IF(Sheet12!B17>0,12,0)),Sheet1!B17,Sheet2!B17,Sheet3!B17,Sheet4!B17,Sheet5!B17,Sheet6!B17,Sheet7!B17,Sheet8!B17,Sheet9!B17,Sheet10!B17,Sheet11!B17,Sheet12!B17)

Add hours from different sheets based on date

I have an Excel file where I have a few sheets. On one I keep track of my hours I work a the office. The other sheet is used to track the hours I spend travelling.
This is sheet1.
Date Hours
27/11 8
28/11 8
29/11 7
This is sheet2.
Date Hours
27/11 0
28/11 0
29/11 4
I would like to have a column on sheet1, that adds the hours depending on the dates. For example,
Date Total Hours
27/11 8
28/11 8
29/11 11
How would I go about doing this?
Assuming that your date column starts in A2, this should work:
=SUMIF(Sheet2!$A$2:$A$4,Sheet1!A2,Sheet2!$B$2:$B$4)+Sheet1!B2
The conventional solution is not to have the travel hours on a separate sheet in the first place (or if they are needed elsewhere to obtain them from the sheet1). When together with the office hours the data is more compact (e.g. the dates only entered once), so requires less storage space, the ‘picture’ provided by sheet1 ‘at a glance’ is more comprehensive (it may not be coincidence that the one day in the example showing travel time is also the one day with below average hours work at the office) – and the formula is simple, not requiring a question on SO, is easier to maintain, faster to process etc.
I would like to have a column on sheet1, that adds the hours depending on the dates.
Assuming consistency in layout (e.g. say Date is in A1 on both sheets), then copying sheet2 ColumnB into sheet1 ColumnC, inserting Total into sheet1 D1 and entering:
=B2+C2
in sheet1 D2 and copying down would appear to meet your requirement and have the other advantages mentioned, though I suspect not quite the solution you wanted. In your last example you do not show the Hours column that you already had in sheet1 and if this is part of your objective you might, after the above, just hide ColumnsB:C.

Resources