I am trying to find a specific column based on month (B1) and count the number of cells with x under it based on by the designated region (D1).
This is what I figured it would be but it is coming back as #VALUE!.
=SUMPRODUCT(SUBTOTAL(3,INDEX($1:$1048576,0,MATCH($B$1,$3:$3,0))),--(($A:$A=D$1)))
SUBTOTAL does not work with INDEX, use OFFSET:
=SUMPRODUCT(SUBTOTAL(3,OFFSET(A3,ROW(1:9),MATCH($B$1,3:3,0)-1))*(A4:A12=D1))
Edit
This version is dynamic:
=SUMPRODUCT(SUBTOTAL(3,OFFSET(A3,ROW(INDIRECT("1:" & MATCH("zzz",A:A)-3)),MATCH($B$1,3:3,0)-1))*(A4:INDEX(A:A,MATCH("zzz",A:A))=D1))
It will automatically resize based on how much data is in Column A. It is set that the title row is in row 3, if that changes then you need to change the 3:3 and the -3 to the row number where the titles are located.
Related
I've faced huge problem with my macro. I have data that contains colums with quantities and values of stock like this:
What I'm trying to achieve is:
to go through every row until the very last, locate quantity (colums with Q letter) and values (colums with V letters) below 0, then adding these quantities below zero to the maximum quantity within the row and adding these values below 0.
to find values within age category for every row that have no corresponding quantity (see cell B4 as example) and add these values to the maximum value within the row.
Why VBA for something you can achieve with a formula?
Let me show you how I calculate the maximum of a list of cells, referring to a column, whose name starts with a "V":
=MAXIFS(A2:F2,A1:F1,"V*")
Screenshot:
Explanation:
Take the maximum of the values on the second row (A2:F2)
The criteria you need to take into account refer to the first row (A1:F1)
The criteria is that it should start with a "V".
I'm looking to calculate the average of a series of cells across multiple tables on the same spreadsheet.
Each manager has a table and in each table, there are a number of statistics e.g. Total Activity, Outbound Calls & Credit. Each table is situated one under the other e.g. Danny's table might be situated on rows 1- 5, Ann's 7-12, Katie's 14-19. I need to find the average for each statistic and output it to my summary page.
I've tried using Application.WorksheetFunction.Average but could not get it working as the range is scattered among various rows. I do however know that each variable appears in every 6th row so I tried For i = 2 To lastRow Step 6 which outputted the values into cells and calculated the averages based on that cell range but I'd rather have something more direct if possible.
Could anyone offer a valid solution to this?
Sample of data beneath. looking to get the average for each of the 4 variables.
Alternative 1
If there are other values than the values you want an average of in column B, you can use SUMPRODUCT.
Enter this formula in any cell in any other column than column B. It will calculate an average of every 6th value starting on row 2.
=SUMPRODUCT(B:B*1*NOT(ISBLANK(B:B))*(MOD(ROW(B:B),6)=2))/SUMPRODUCT(1*NOT(ISBLANK(B:B))*(MOD(ROW(B:B),6)=2))
B:B Array of all values in column.
1*NOT(ISBLANK(B:B)) Array of 1 or 0, 1 on non blank cells in column B, 0 for blank cells.
1*(MOD(ROW(B:B),6)=2) Array of 1 or 0, 1 on row 2, 8, 14 and so fourth
SUMPRODUCT(B:B*1*NOT(ISBLANK(B:B))*(MOD(ROW(B:B),6)=2)) sums all non blank cells in column B on every 6th cell starting at row 2.
SUMPRODUCT(1*NOT(ISBLANK(B:B))*(MOD(ROW(B:B),6)=2)) counts all non blank cells in column B on every 6th cell starting at row 2.
To speed up the formula you can replace B:B with for example B1:B100 depending of the number of rows that have values.
Alternative 2
If there are nothing but values you want an average of, then you can use SUBTOTAL as suggested by Dominique. =SUBTOTAL(1,B:B)
I have different spreadsheets (on the following photo, from 1 to 25);
They have the same layout ( Photo here ).
I want to create a table with the E7 cell of each spreadsheet (A table of every "Total").
I tried this by extanding the formula...sounds good, doesn't work.
Put this in the first cell:
=INDIRECT("'" & ROW(1:1) & "'!E7")
And copy down.
If you put the following formula in the first 25 rows of your target sheet, it should do what you're trying to do:
=INDIRECT(ADDRESS(7,5,1,1,ROW()))
ADDRESS is formatting an address based on the parameters provided.
7 is the row
5 is the column (Column E)
1 says use an absolute reference $E$7
1 says us the A1 style address, not the R1C1 style.
ROW() says use the sheet having the same name as the row where the column appears. So, in row 1, it will use sheet named "1". In row 8, it will use the sheet named "8"
INDIRECT says to get the value from the provided address.
If you need to put the list in a set of rows farther down the sheet, just use ROW()-N where N is one less than the number of rows from the where your list starts. So, if your list of totals starts in row 3, use ROW()-2.
Looking to add a cell function that counts the number of blank cells in a column, but only to the bottom row of data. Each row in my spreadsheet is a customer order and the sheet keeps track of order assembly progress, each task is grouped into a column and if the cell is blank it means it is yet to be finished.
Tasks include columns F-K, other rows will not be counted
Goal: Number of incomplete(Blank) tasks in a column will be shown as a number at the top of the sheet.
Problem: When using =COUNTBLANK (x3:x) The function counts all blank rows to the bottom of the sheet, Need to limit this to the bottom of the data. That number changes depending on how many orders are on the sheet so this number needs to be adaptive to the bottom of the data(Last order)
Link to copy of Sheet: Order Priority Sheet
Any Additional Information, misunderstandings, or questions please ask. I understand if my descriptions were not clear and would be more than happy to help you help me!
Try:
=COUNTBLANK($A$3:INDEX($A:$A,LOOKUP(2,1/(LEN($A:$A)>0),ROW($A:$A))))
adjust the column references for your desired column
This part of the formula:
LOOKUP(2,1/(LEN($A:$A)>0),ROW($A:$A))
returns the last row number in column A that appears blank.
However, if, for example, you wanted to count all of the blanks in the range F3:Kn where n is the last used row in column A, then try this modification:
=COUNTBLANK($F$3:INDEX($F:$K,LOOKUP(2,1/(LEN($A:$A)>0),ROW($A:$A)),6))
If you just want to count each column separately, again, using column A to determine the last relevant row, then, (for column F):
=COUNTBLANK(F$3:INDEX(F:F,LOOKUP(2,1/(LEN($A:$A)>0),ROW($A:$A))))
and fill right
Column A seems to be a column where the last populated cell defines the extents of the data. Dates are considered numbers so the row with the last populated date in column A would be,
=match(1e99, a:a)
To count the blanks in F3:<last cell>,
=countblank(f3:index(f:f, match(1e99, $a:$a)))
I am working with Microsoft excel 2010. I have different dates like column E1:E19 that are not in specific interval. I want help to find only starts month date and paste them into G column like shown into the figure.
First of, is to say - both K_B and Ibrahim Odeh have valid and good attemps. I just want to add another option, because those options use additional rows or manual tools.
Here is the formula I came up with to solve this as shown in your screenshot - just one column, just the rows with the starting dates:
G1=SUBTOTAL(5,E$1:E$19)
G2=SUBTOTAL(5,OFFSET(E$1:E$19,MATCH(EOMONTH(G1,0),E$1:E$19,1),0,ROWS(E$1:E$19)-MATCH(EOMONTH(G1,0),E$1:E$19,1)))
It is possible to use this for the whole column, like this:
G1=SUBTOTAL(5,E:E)
G2=SUBTOTAL(5,OFFSET(E:E,MATCH(EOMONTH(G1,0),E:E,1),0,ROWS(E:E)-MATCH(EOMONTH(G1,0),E:E,1)))
And now, some explaining:
First, you need a starting point in G1 - so we use SUBTOTAL to get the earliest date in column E, using MIN (which is 5).
Now we work from here, by offsetting the range which we use to calculate our SUBTOTAL, still using MIN (5), to get the beginning of each month.
The trick is OFFSET. The first parameter is out basic range, which we will offset, then we have to determine how many rows to offset, and to not get an error, we use ROWS(basicRange) - rowOffset to always stay in out range.
MATCH is used to determine the necessary offset, by looking for the row of the last listed date of the month from G1 using EOMONTH.
Hope this clears any question.
Edit:
Because I do have to translate this, here is the original:
=TEILERGEBNIS(5;E:E)
=TEILERGEBNIS(5;BEREICH.VERSCHIEBEN(E:E;VERGLEICH(MONATSENDE(G1;0);E:E;1);0;ZEILEN(E:E)-VERGLEICH(MONATSENDE(G1;0);E:E;1)))
as long as your dates columns is sorted as it looks in the example then do the following:
insert a row above row 1 (for use of the formula)
enter a formula in column A in all rows that your table has. The formula reads:
=If(NOT(YEAR($E2)&MONTH($E2)=YEAR($E1)&MONTH($E1), MAX($F$1:$F1)+1, "")
This will add increasing numbers from 1 to the number of months involved only next to the first date in your table for that month.
Then in your table in column G put:
=VLOOKUP(ROW(), A:E, 5)
you can drag this formula down as far as you want. The formula finds the first record in A:E that matches the row number in G (ROW() in G1 returns 1), Then VLOOKUP() will return the value in the 5th column in A:E (which is column E with the date).
The Formula in column A should be to the left of the dates for the VLOOKUP() formula to work.
Alternatively you can put it in a column to the right but then use another formula in stead of VLOOKUP() in column G:
=SUMIF(F:F,ROW(),E:E)
This sums all values in E for rows where the value in F matches the row number of the cell in G.
I think you need to use analysis-toolpak Add-on to perform this task:
check out the following URL if you need to know how to load it:
http://office.microsoft.com/en-us/excel-help/load-the-analysis-toolpak-HP001127724.aspx
Regards