Building an Excel table based on specific cells from another sheet - excel

I am making a table of averages based on a large table in another sheet.
The original table has 27 samples each with 3 repetitions of "sample name" in column D along with 3 repetitions of "data" in column H through O
ex: Cells D4-6 "22L9" Cells H4-6 "0.21","0.32","0.23"
D7-9 "22p3" H7-9 "0.11","0.42","0.43"
The new table I want to auto-populate column A in the new sheet the first rep. of "sample name" from the original table, in column B an average of the three "data numbers" from H, column C from I, and so forth.
I have tried =AVERAGE('Sample data A'!H4,OFFSET('Sample data A'!H4,3,0))& =AVERAGE('Sample data A'!H7,OFFSET('Sample data A'!H7,3,0)) and filling down but it does not skip cells in the next formulas

I think I understand what you’re trying to do. Even if I haven’t nailed it, I hope this approach gets you started.
Instead of doing the selecting yourself using OFFSET(), let Excel do it for you by using AVERAGEIF(). AVERAGEIF() says “average only those values from column B in rows where column A matches some value.
Let’s say you enter “22L9” in cell A2, “22p3” in cell A3, etc.
Then in cell B2:
=AVERAGEIF(‘Sample data A’!$A$2:$A$50, A2, ‘Sample data A’!$H$2:$H$50)
And then copy that down for how ever many column A values you have. In my formula, I used A2:A50 and H2:H50, I leave it to you to make those ranges match whatever rows contain your data.

Related

Rearrange whole rows, based on a variable depending on formula result, after sorting the source table

I have an issue with using data from a source table:
Lets say we have Sheet 2, where in column A is the formula
=IF(Sheet1!A1 = 0;"";Sheet1!A1)
I am taking only the newest info form Sheet1 to keep another type of data in Sheet2 about the given value. In columns B,C & D in Sheet2 I have manually input data, relating to the result value from Column A.
The issue is that the information in Sheet1 needs to be kept chronologically, so if the last(newest) row is with an earlier date, Sheet1 needs to be sorted by date. This of course automatically sorts the values in column A of Sheet 2, based on the formula. However, all data in B, C & D is still based on the values, before the sort, as it is manually input.
Is there a way to move around the whole rows in Sheet2, based on the value in column A, when sorting Sheet1?
The only resolution I could think of is to paste the formula results as values, but the table would not be as dynamic anymore.
Thank you in advance!

Excel VLOOKUP using 2 colums from a table array

I have the below VLOOKUP formula
=IFERROR(VLOOKUP(#B5:B64,dbVEH!$A$2:$E$296,5,FALSE),"")
I am trying to create a formula that searches 2 columns on the table array. I have the range A$2:$E$296 however it only matches the A column and delivers the result from the E column.
I am trying to create a formula so that if Cell B5 on my main sheet = anything in column A OR anything in column B on the "dbVEH" sheet then display the result from the 5th E column on "dbVEH" in cell B5 on my main sheet.
My reasoning behind this is that I'm trying to cover alternative spellings inputted into B5:B64 on my main sheet. One cell could have "Thomas" and another cell could have "Tomas" but they both need to equal the same result. My table on sheet dbVEH has the first column "Thomas" and the second column "Tomas" to cover the different spelling types.
VLOOKUP will not do that. Use FILTER:
=#FILTER(dbVEH!$E$2:$E$296,(B5=dbVEH!$A$2:$A$296)+(B5=dbVEH!$B$2:$B$296))

Excel formula to pull data from last 5 rows of a cell range that has new rows added daily

As the title suggests, I have a worksheet (sheet1) that has lots of data that spans columns A-E and with rows that are added daily, What I want to do is on a separate worksheet (sheet2) show the data from the last 5 rows of sheet1.
Providing there is continuous data within column A on Sheet1, you could also use the INDIRECT() and COUNTA() functions.
=INDIRECT("Sheet1!$A$"&COUNTA(Sheet1!$A:$A)-4)
=INDIRECT("Sheet1!$A$"&COUNTA(Sheet1!$A:$A)-3)
=INDIRECT("Sheet1!$A$"&COUNTA(Sheet1!$A:$A)-2)
=INDIRECT("Sheet1!$A$"&COUNTA(Sheet1!$A:$A)-1)
=INDIRECT("Sheet1!$A$"&COUNTA(Sheet1!$A:$A))
You would need to amend the column letter within the INDIRECT function for each column of data which you wish to view on Sheet2.
In an appropriate cell on Sheet2, use this formula,
=INDEX(Sheet1!A:A, MATCH(1E+99, Sheet1!$A:$A)-(ROW(1:1)-1))
Fill right for a total of 5 columns then fill those 5 cells down 5 rows.
That formula will find the last number in a column. This is often the case as the left-most column mat hold an ID number. The same reference point should be used to collect cell values from other columns to avoid the confusion that a rogue blank cell would create.
If all you have are text values then the formula in the first cell would be,
=INDEX(Sheet1!A:A, MATCH("žžž", Sheet1!$A:$A)-(ROW(1:1)-1))
Fill right and down as described above.

Sort row data into columns with same heading in excel 2010

Put simply, I need to sort row data for a specific range into the correct columns based on that columns heading. For example, if there are five columns labelled A through E, and data in the rows below ranging from A through E; I need all of the A's to be in the A column, all of the B's in the B column etc.
Example start data:
How it should look after the sort:
It also must be able to work with the possibility of having empty cells. For example; if the first example data had no B in row 3, the data must not shift over to the left so that C is in the B column etc.
Other info: not feasible to do by hand - over 450 rows.
It also must be able to work with the possibility of having empty cells.
Taking the above into consideration.
NON VBA WAY
Insert enough columns so that the data moves to the right
Next in the row one, duplicate the values from your data
Next in Cell A2 Put this formula
=IF(COUNTIF($H$2:$L$2,A1)>0,A1,"")
Copy the formula to the right
Next remove "$" from the table range and add it to the header in formula in Cell A2 so that we can copy the formula down. This is how it would look
=IF(COUNTIF(H2:L2,$A$1)>0,$A$1,"")
Similarly your B2 formula will look like this
=IF(COUNTIF(H2:L2,$B$1)>0,$B$1,"")
Change it for the rest
How highlight cells A2:E2 and copy the formula down.
Your final Sorted Data looks like this.
Copy columns A:E and do a paste special values on Col A:E itself so that the formulas change into values and then delete Cols H:L

How can I write a database like query in excel using just functions?

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.

Resources