I'm trying to build report from external workbooks on servers. Can't use Pivot, it takes too long to load data and refresh.
I have plain table with data, and need to create Matrix type table, where Column B stays as Col B values, and Col C ++, goes to be headers (in row) and data filtered by date in B2. Then count duplicates from data table that match col headers and Col B rows, and put result in cell. And count SUM.
New to VBA, don`t know how to aproach that. Newbie in simple formulas and formatings.
Hope someone can help.
product data:
result:
You can use a single COUNTIFS() to complete the results table.
In the first sheet, I have named the ranges appropriately (see the grey text at the end, that's what I named that range):
Then, in the results sheet, simply copy "ordered"/"Undelivered" down, then starting in D5, place this formula and fill in your table:
=IF(COUNTIFS(date,$B$1,orders,$B5,transport,$C5,product,D$3)=0,"",COUNTIFS(date,$B$1,orders,$B5,transport,$C5,product,D$3))
(the red highlighted area is where the formula is filled in). And of course, if you don't want to see the repeated "ordered"/"undelivered", simply set the font to white.
Related
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.
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!
Maybe I'm using ´VLOOKUP´ wrong, but I've tried even using a table array. It continuously returns a ´N/A´ or ´#REF´ error back to me.
The spreadsheet is setup with a sheet titled 'Character', ´C6´ is a drop down menu, and ´D6´ is where the ´VLOOKUP´ formula is being written. I have a 2nd sheet listed named, 'Weapon', which is a 13 row sheet with various different text and numerical data information. I'm only trying to pull the numerical data from the 6th row, or column F.
So, this is the function I'm writing:
´=VLOOKUP($C$6,Weapon!$A$2:$M$78,6,0)´
What's odd about this is if I check
´=VLOOKUP($C$6,Weapon!$A$2:$M$78,1,0)´
It will return the text data of the first result in the A column on the 'Weapon' sheet, but it won't return anything else in B,C,D,E,etc. columns if I change that 1 to a 2,3,4,5, etc.
Any insight would be great.
For VLOOKUPs to work, it's the lookup value that is the critical part. And that critical part has to be unique and it has to be in the first column. Your table of data on the Weapon sheet has "Staff" in Column A.
A quick fix for you is to change your formula to
=VLOOKUP($C$6,Weapon!$B$2:$M$78,5,0)
Notice the left-most column of the range is now column B and we're getting data from the 5th column.
This assumes that your values in column B are unique and will match up with the values in your drop-down menu in C6 on the Character sheet.
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
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.