Sumif for dynamic range of columns - excel

Hi I have store numbers in different columns and products in rows with sales for respective stores. I want to do sumif in a different sheet by changing stores and products in data validated cells. How do I select dynamic columns in Sumif based on store numbers. Attaching image for reference.

Here's a mockup based on your sample data, with row numbers and column letters shown:
Using that as a base, in cell C15 is this formula:
=SUMIF($C$3:$C$9,$C$14,INDEX($D$3:$G$9,0,MATCH($C$13,$D$2:$G$2,0)))
You'll need to adjust the ranges to suit your actual data.

=SUMIF(A2:A6,"=Shirts",B2:B6)
A2:A6 - This is the range over which the condition applies
"=Shirts" - the conditional expression.
B2:B6 - The cells under consideration for summing up.

Related

Auto-copying values from adjacent cells to non-adjacent cells in excel

enter image description hereI need to make an auto-fill of values from adjacent cells in table to another non adjacent cells of another table, for example, I need to get the following:
Source values: C7,C8,C9 ...
Destination: G4, G7, G10 ...
Thanx
I'm curious about your use case for this. I also have questions:
Are the source and destination always ordered? Meaning the names appear in the same order in both? Are these both on the same sheet as in your example? Are there always 3 cells per name in the destination?
I can't think of a formula that would give the desired result, but here's an approach I would take.
Make sure your source values and destination are on separate sheets.
Create a helper column in your source value range numbering your rows of data 1...x
Copy cells 1...X and paste them directly below you last row of data two times. So you should see 1...X repeat twice.
Sort your helped column least to greatest - you should now have two empty rows between each row of data.
Copy the column of data you need and paste into your destination. Because of the empty rows it should preserve your spacing.
You can achieve this with VLOOKUP. Use this formula in the Destination table.
=VLOOKUP(G3,Source,2,FALSE)
G3 is the cell in which the name, e.g. "Mike", is written. In your sample this appears to be a merged cell. Note that in merged areas all cell content is always in the first cell. So, if G3:G5 are merged, nothing can be retrieved from G4 or G5 because all content is in G3.
Source is a named range of 3 rows and 2 columns, as per your example. If your source is a true table you can use its name. VLOOKUP requires that the name must be in the first column of the range you specify. You can also specify a hard range, if you don't like using names. In my example the Source range was $A$4:$B$6.
2 is the column in Source from which to return the result.
False specifies that you don't want an approximate match (but an exact one).
Of course, this method works in the direction opposite to your diagram. The formula is in H3 in my test sheet. This is because there are no formulas in Excel that write to cells they don't themselves occupy.

How to define excel SUMIFS criteria considering any text and numbers?

My SUMIFS formula criteria is based on a cell (say A1) that is data validated by list and changed via selection by user. If cell has data inside text or number by selection from drop down list, SUMIFS formula is considering that data as criteria to calculate the related sum. If criteria cell is left blank, I want formula to sum everything without any condition. My problem here; in criteria field of SUMIFS formula, I typed if condition like; SUMIFS(sum-range,criteria_range,IF(A1<>"",A1,"*")) but in this case excel considers only text values and do not include cells containing number. Briefly, if nothing selected in A1, I want SUMIFS formula to sum everything without any condition, numbers, texts and even blank cells. How can we proceed to do that?
EDIT:
Here an example for data and formula, what is expected is actually to disable criteria if one of selection is blank on left. Harun's suggestion works but if there is blank cell in criteria range, then in this case it won't consider those values in sum. For instance, if we select from left Phone/smart/touch, then how can we get "2" as output no matter what is in cri_range4 cells? Thanks
Example:
How about this solution? It basically ignores a missing entry in column C and evaluates only the other two. (Your example formula has a fourth criterium that isn't apparent in your list but the method can be extended for as many criteria as you might have.
=SUMPRODUCT((IF(LEN(C2),(INDEX(Lists,,1)=C2),TRUE))*(IF(LEN(C3),(INDEX(Lists,,2)=C3),TRUE))*(IF(LEN(C4),(INDEX(Lists,,3)=C4),TRUE))*SumRange)
For better readability I created a named range Lists which comprises your sample range E2:H10 while I named I2:I10 as SumRange'. INDEX(Lists,,1}` refers to the first column of the range. It's important that SumRange and Lists have the same number of rows.
If A1 is blank then just use not equal operator to sum all cells that are not blank. Try below.
=SUMIFS(D1:D5,C1:C5,IF(A1<>"",A1,"<>"))
Edit: can you check below formula in D3 cell then drag down.
=IF(C2="",SUM($I$2:$I$10),SUMPRODUCT(($E$2:$H$10=C2)*($I$2:$I$10)))

Excel Formula: Excluding some columns from formula based on header

I have a COUNTIF formula that counts a particular value across a range of columns in each row. However, I would like to exclude the cell values in a particular column based on the column header.
For example, I need to count the number of cells that contain the value 'NS' across a range 'C:Z' for each row in the worksheet. However, I need to exclude the values in cells that have a column header 'RC'. The challenge is, I cannot control where these 'RC' columns appear in the range. Therefore, I am looking for some mechanism through which I can check whether the column header is 'RC' or not, and if it is, then exclude the cell values from the COUNTIF formula.
Is there anyway to do this?
Use COUNTIFS:
=COUNTIFS(C$1:Z$1,"<>RC",C3:Z3,"NS")
EDIT:
As noted by #JvdV, if you are just looking for a single formula to count all instances (i.e. not row-by-row), you can use =SUMPRODUCT((C1:Z1<>"RC")*(C2:Z100="NS")), changing the 100 to your last row as necessary.

how do I average three columns where the criteria changes each month..ie last three monthly data

I have three columns for each month. I need to average the value in the third column of each month for the last three entries. Can I write a formula that will select the last three entries in the designated range and calculate the average.? And to do this for multiple rows where the data may not be in the same columns?
My level of skill in using Excel is very limited, but I am trying to learn, I would very much appreciate any help that may be forthcoming.
You can use the AVERAGE() function in a cell on the same row. The arguments for the function will be the cells you wish to average.
Can be a series of cells (A1,B1,C1....) or a range (A1:C1). If you use cells from all over the spreadsheet. The copy function uses the relative position by default.
Once you have the function working in a particular row, you may copy that formula down to the other rows in the spreadsheet. Excel will automatically change the formula to include the corresponding cells from the same row the formula is being copied to.
For additional info on this function, visit:
http://office.microsoft.com/en-ca/excel-help/average-function-HP010062482.aspx

extracting a specific cell when specific column and row paramteres are met

I have an excel spreadsheet that contains 16 columns and 100 rows. In each cell is a specific number.
The header columns contain specified numbers as do the row headers.
On a seperate sheet within the workbook is a calculator that people can input numbers to calculate engine perfomance figures.
What i am after is that when a specific number is inputed corresponding to a number in the header column, along with a specific number from the row header the number corresponding to the interestion of those two numbers will automaically populate in the calculator cell sheet.
I am very new to excel, and have had minimal experience in writing or inputting code.
Any assistance in this would be greatly appreciated.
Cheers
Andrew
I assume your data sheet looks something like this but with more columns and more rows. You can use a combination of VLOOKUP and HLOOKUP to achieve what you want.
In my example the formula in D11 is:
=VLOOKUP(D9,A1:F6,(HLOOKUP(D10,A1:F6,1,TRUE) + 1),TRUE)
You need to change the parameters of this to match your dataset, the user inputs in D9 and D10 and the product is displayed in D11.
The "standard" approach is to use INDEX with two MATCH functions based on column and row headers, e.g.
=INDEX(Table_without_headers,MATCH(Z2,row_headers,0),MATCH(Z3,column_headers,0))
where Z2 and Z3 contain the search values

Resources