Copy all excel rows into one row - excel-formula

How can I copy all rows into one row? Not concatenate the cells. I have a big table with multiple data rows and want them all to be on a single row without having to copy paste (there are about 800 rows and 10 columns).
For example I have a table with two rows, 2 values each row such as:
row A1: m, n
row B1: x, y
I want it to become 1 single row with 4 values in it (each value in a column):
row A1: m, n, x, y
Thank you.

Isn't concatenate, in concept, what you're asking to do?
I have a somewhat similar scenario where I often combine all data into one long string.
If you have column A with data in rows 1 and 2:
m, n
x, y
In cell B1 for example (the same row as the first row of data), you could enter the formula "=A1". In cell B2, you could enter a formula to create the text equivalent of a running total. Choose your delimiter, such as a space, comma, or a space+comma. So, in cell B2, you could enter the formula "=B1&", "&A2". This says, "take what is in the cell above me (which is the same as the first entry) and add the value of the next row entry." Once you do this second formula, you can copy this formula down (using auto-fill) your entire list (e.g., 800 rows).
If you need 1 row but still need 10 separate columns, you simply do this formula 10 times (once for each column). Once you've done all the formulas, go down to the last row, copy - paste special - values, and you will have your data. You can then delete your 800 (or however many) rows.
Let me know if this does NOT make sense.

I found a solution, it's more complex than I imagined. I have to use a formula:
=OFFSET(Sheet1!$A$1,((ROW()-1)*5)+(FLOOR(COLUMN()-1,4)/4),(COLUMN()-1)-(FLOOR(COLUMN()-1,4)))
Here's the link:
Copy all rows into one row

Related

Excel: How do I efficiently condition a cell so that I can identify a cell with observation counts less than a certain number?

Basically I wanted to only extract the top 2 rows for every Entry #, but if the Entry # does not have 2 rows it is not used.
I tried IF statements and eliminating blanks and whatnot, but if this is a large data I would not be able to handle it.
If you don't mind adding a few columns, here's one method. Arrange how you wish.
Column's B and F are your original data.
Column C, in cell C2, input your first value manually (1 in this case).
Then here's the formula for Cell C3:
=IF(ISBLANK(B3),C2,B3)
Cell D2 formula:
=IF(C2=C1,D1+1,1)
Cell E2 formula:
=IF(COUNTIF(C:C,C2)>1,"Yes","No")
Drag down your formulas.
Then you can filter on column E for YES, and filter on column D for 1 & 2.

Excel Count specifc value across range of columns, but only once per column

I have been trying to work out how to count the number of times a value appears across a range, but only once per column.
Using the example data below, the results I want to get to are shown in the end cells. Using the =COUNTIF(A3:G5,J3) counts every time a name appears, causing double-ups on some days.
How can I make it count each name once per column, but across multiple columns (there would be 1 column for each day of the year in the real data)
Thanks
in A7 enter:
=IF(COUNTIF(A3:A5,$J$3)>0,1,0)
and copy this across to G7. then in H7 enter:
=SUM(A7:G7)
You also can count values using single array formula:
=SUM(--(MMULT(TRANSPOSE(--($A$2:$G$4=I2)),ROW($A$1:$A$3)^0)>0))
Array formula after editing is confirmed by pressing ctrl + shift + enter
So the final question is 'count how many columns the name appears in'?
In which case you need a hidden row at the top or bottom of the sheet that contains everything in that column. Say it's row 1:
a) The formula in A1 would be =CONCAT(A3:A5), B1 would be =CONCAT(B3:B5) and so on (where the range covers rows 3 to 5). CONCAT sticks text strings together.
b) the cell doing the counting would be =COUNTIF(A1:G1, "*J3*"). What that does is check which cells in A1:G1 contain J3 among other things.
And voila, problem solved.

How can I expand a dynamic range with blanks between cells?

I want to define a dynamic range that will expand the rows and columns of my range whenever a new row or column is inserted. My current formula does not want to expand to cell $T$13. My headers start in row $M$7. How can I adjust my formula?
Formula Being Used
=OFFSET(Sheet1!$M$8,0,0,COUNTA(Sheet1!$M:$M),COUNTA(Sheet1!$1:$1))
I need my range to expand to cell $T$13
Right now, your formula counts the number of text values in column M.
That is not a robust approach because column M contains only five text values, but columns S and T have many more values.
If you don't know which column may have the most number of entries, you can introduce a helper cell in each column that counts the number of entries below. I suggest you insert a new row 2. In column M, for example, put a formula in M2
=counta($M$3:M$99999)
Copy that formula across to column T.
Next you can evaluate which of the columns has the largest number
=max(M2:T2)
This can be plugged into your original formula like this:
=OFFSET(Sheet1!$M$8,0,0,max(M2:T2),COUNTA(Sheet1!$1:$1))
So now, instead of just looking at how many rows are in column M, the formula uses the maximum number of rows in the columns M to S.
You can now hide row 2 if it upsets your worksheet design.
Edit: the mere count of text values with CountA will ignore blank cells and will return incorrect results. You really need a formula to find the row number of the last populated cell in each column.
This should really be a new question, but here goes
If the column has number values you can use
=MATCH(99^99,B5:B999,1)
If the column has text values you can use
=MATCH("zzz",C5:C999,1)
Adjust your ranges accordingly.
I ended up using the solution mentioned by #tevlyn.
In range$M2:$T2
I have the follolwing formula =IFERROR(MATCH(99^99,M$8:M$999,1),0).
I've added IFERROR because my data doesn't always have data stretched to $T2.
I then defined my range in name manager using:
=OFFSET(Sheet3!$M$8,0,0,MAX(Sheet3!$M$2:$T$2),COUNTA(Sheet3!$1:$1))
This still works even if there are blanks in between the range.

MS Excel: SUMIF where the criteria is a range of non continguous cells

I would like to add up every 8th column in row 7 (starting at M7), where the contents of the 8th column in row 2 (starting at M2) ALL equal the contents of cell I6.
Row 7 is numbers.
Row 2 and cell I6 are text.
Can anyone help please?
Thanks for reading.
Clara
You can use a single formula with a similar approach to that suggested by Dan, i.e.
=SUMPRODUCT((MOD(COLUMN(M7:IV7)-COLUMN(M7),8)=0)*(M2:IV2=I6),M7:IV7)
Note the use of two COLUMN functions which will ensure that the formula still gives the same result if columns are inserted before the data.
I used column IV as the last column - (it's the last column in Excel 2003) - adjust as required
Of course this would be much easier to do if there was a common header value in row 1 to identify the columns in question, e.g. if M1, U1, AC1 etc. all contain X then the total can be calculated using SUMIFS like this:
=SUMIFS(7:7,1:1,"X",2:2,I6)
You could use mod to decide if it's an "8th" row or not, after that it's easy if you just create a bunch of helper rows
(move rows down as necessary)
in row X use the formula (dragged across all columns) =(MOD(COLUMN(A1), 8) == 5)*1 to get 1s in 8th columns starting at column M (hence the =5). Note that the *1 is to convert the TRUE/FALSE to 1/0. Also note this returns true for column E which you can manually ignore.
in the next row enter the formula =A2=$I$6
In the next row just add the previous two rows (you can really combine all three of these rows into on row with the formula =(MOD(COLUMN(A1), 8) == 5) + (A2=$I$6)
SUMPRODUCT this last row with row 7 in the cell that you desire this final sum to be

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

Resources