I have an Excel sheet as below-
Cell No / Column A
-------------------
1. Total
2. $1,350.00
3. $2,670.00
4. $2,891.00
5. $1,107.00
6. Drop-Down List
I have added Data Validation List with some function name like MIN, MAX, SUM.I want to calculate the value of A2:A5 cell and display in A6 cell, if i select any of one function in A6 cell, which is added through data validations. Suppose I select SUM form in A6 cell, it will show sum of value function like SUM(A2:A5).
How can I do that?
You can simply create these three formulas in Column B, say, MIN in B1, MAX in B2, SUM in B3.
Then pull your data validation drop down list from these cells which already contain that formula.
However you need to format your B1, B2, B3 cells so that in data validation list you see for example MIN, MAX or SUM. I have done this for you in this dropbox link
like this:
here is the preview
You can hide column B so that nobody can make any changes to it. I have also selected the entire column range in column A in the formulas so if you add anything later to that column it automatically calculates them alL.
You can add as many formulas to column B as you want,and then put them in your data validation dropdown menu. Don't forget to format your cells in column B. You should custom format it and put your desired text inside "", like "MIN PRICE".
Related
Cell B2 has the value for demand, Cell C2 has the value for revenue, Cell D2 has the value for cost, and Cell E2 has the value for profit. In the worksheet, there is a table (or simply put, data) that generates the values for revenue, cost, and profit for any demand between the range 1 to 40. Thus, whenever I update the value in cell B2 to any integer between 1 and 40, the values in cells C2, D2, and E2 change accordingly.
What I want to do is, create a table with columns for demand, revenue, cost and profit. I manually entered the row data for demand, that consists of integers from 1 to 40. Now, I want to have data automatically entered into the rows of other 3 columns for all matching values of demand. For example, row 1 will have demand value 1, and the corresponding values for revenue, cost, and profit (as generated by cells C2, D2, and E2 when cell B2 is 1). Is there a function or VBA I can use to enter corresponding values automatically into all the rows (1-40)? Otherwise, I have to change B2 manually and enter the corresponding values for revenue, cost and profit all manually into the table, one by one. The reason why I need the table is to generate a line chart. Thus, if there is any other idea you've got, also appreciated.
For a simple solution that seems to work for you.
Use the current formulas you are using for the Revenue, Cost, and Profit within the table to calculate them. If you aren't familiar with Excel you can enter the formulas in the first row with respect to the Demand value and drag down from the bottom right hand corner of the cell to automatically copy the formula to the below cells.
Then for your B2, C2, D2, and E2 cells you could use VLookup to choose the correct values from the table based on the entry in cell B2.
If you linked an image of what you are trying to do I could give exact formulas but I believe this would work for your instance.
Sheet 1 goes like this:
Sheet 2 should be like this:
ITEMS QUANTITIES
APPLE 4
GUAVA 2
Sorry for writing the spreadsheet in here, as I'm not allowed to include more than 1 image yet.
Suppose you have the following named ranges:
ITEMS being the data in ITEMS column on your Sheet1;
QUANTITY being the data in QUANTITY column on your Sheet1.
Enter the following formula in Cell D2 on your Sheet2:
=IFERROR(INDEX(ITEMS,MATCH(0,COUNTIF($D$1:D1,ITEMS),0)),"")
Please note it is an array formula which requires you to press Ctrl+Shift+Enter upon finishing the formula in the formula bar.
Drag it down until there is no more items showing up.
Then you can enter the following formula in Cell E2 on your Sheet2 and drag it down:
=SUMIF(ITEMS,D2,QUANTITY)
As you can see from the above screenshot, there may be some empty cells in Column D as I used IFERROR to return blank cells if there is no more distinct item. The corresponding quantity will be 0 consequently. You can choose to delete them or hide them on your worksheet.
By the way I am not sure why Pivot Table is out of the picture as it is actually a faster and easier approach than formula and you do not have to worry about the blank cells returned by the formula if the number of unique items is uncertain. All you need to do is to highlight the source data, insert a pivot table, and put the ITEM in Rows and QUANTITY in Values field.
EDIT: Update to also extract unique distinct values:
Enter this formula in cell A2 of Sheet2:
=IFERROR(LOOKUP(2,1/(COUNTIF($A$1:A1,Sheet1!$A$2:$A$300)=0),Sheet1!$A$2:$A$300), "")
Change 300 to the actual last row of your data and copy that formula down until it returns empty cells.
Then just use a regular SUMIF in cell B2 of Sheet2:
=SUMIF(Sheet1!A2:A300, A2, Sheet1!B2:B10)
Then, type whatever fruit you're looking for incell A2 of Sheet2. Continue like this in the following rows for all the fruits you need.
I have a column with a drop down list of options. Based on the results of this selection I would like a cell in the following column to enter a corresponding value.
In other words, If I have selected 'Porridge' from my drop down list in A1, I would like it to automatically update B1 with £2.00. But if I select 'Apple' in A1, I would like it to update B1 with £1.00 and so on for a number of results.
How about this as your formula:
=VLOOKUP(A1,{"Porridge",2;"Apple",1;"And so no",3},2,FALSE)
If you want to return text values instead of numbers then:
=VLOOKUP(A1,{"Porridge","£2.00";"Apple","£1.00";"And so no","£3.00"},2,FALSE)
I'm trying to do something in Excel without using VBA macros. I suspect it is possible, but have some up empty so far. Basically for values in a table, I'd like to retrieve a list of all values in Column A conditionally where Column B equals a value I provide.
For example I'd like a function that essentially returns a range/description of cells for Column A if Column B is equal to zero.
Column A Column B
1 0
2 0
3 1
4 0
would return a range describing cells a2, a3, and a5 (1, 2, 4). I'd prefer to be able to do this using a formula, and not manually using pivot tables. I would be willing to create a view of the data using pivot tables if that table could then be referenced via a function to give me the appropriate results. I am also able to sort Column B in any way if it makes it easier to do this.
Ultimately I need to pull out a random value from Column A that meet the criteria of Column B in case that matters in the final solution.
Thanks.
Use an array formula.
Type in:
=INDEX($A$1:$A$4,SMALL(IF($C$1=$B$1:$B$4,ROW($B$1:$B$4)),ROW(1:1)),1)
then press Ctrl+Shift+Enter. Drag and fill the cells below until #NUM! shows up. This formula assumes the value you're looking for is in C1 and there are no headers (data starts in 1st row rather than 2nd).
I have some data that's structured in a table like this:
.
I have another tab on my spreadsheet where I eliminate any duplicate category entries and want to concatenate the data to look like this:
I need to create this using a function and not a macro or Visual Basic. I've already written the function to eliminate any of the duplicate category entries and now I need to figure out how to take each of those unique categories and append the data behind it. Any ideas?
Assuming the first image comes from Sheet1 and the second Sheet2, here's a way to do it. You need to add at least one calculated column to Sheet1 and optionally two calculated rows to Sheet2.
Uniquely identify each row on Sheet1. Add a new column A with the formula =B3&COUNTIF($B$3:B3,B3) in A3 and fill down. You'll have first1 in A3, first2 in A4 and so on.
Identify each block of columns on Sheet2. Add a new row 6 with the formula =COUNTIF($B$2:B2,B2) in B6 and fill across. The values will be 1,1,1,2,2,2,3,3,3. You can type these in manually if you like but it won't scale as easily.
Work out the column of each data item in Sheet1 and put in the columns for Sheet2. Add a new row 7 to Sheet2 with the formula =MATCH(B2,Sheet1!$A$2:$E$2,0) and fill across. The values will be 3,4,5,3,4,5,3,4,5. We now know, for each cell in Sheet2, which instance of the category we have and in which column the data variable comes from.
Use VLOOKUP to find first1 and return data column 3 within the data table. On Sheet2, set cell B3 to =VLOOKUP($A3&B$6,Sheet1!$A$2:$E$8,B$7,FALSE) and fill down and across.
You'll have a number of #N/A errors (e.g. cell E4). If you have a newer version of Excel, you can use IFERROR() to escape this; otherwise, use =IF(ISNULL(<formula>), "", <formula>) where <formula> is the formula in step 4.
To summarise:
Create a unique, sequential, calculable row ID for each row in the source.
Determine which instance of that sequence is used by each column in the destination. This is appended to the end of the category to determine the row IDs formed in the previous step.
Determine which column contains the data for each column in the destination.
Look up the row with the calculated row ID and find the relevant column for this data item.
Format the results appropriately.