With the use of a MS Excel Formula; I would like an array formula that will remove blanks rows across multiple columns.
Unfortunately and unlike the use of other similar formulae (i.e., =INDEX($B$3:$B$10,SMALL(IF(ISBLANK($B$3:$B$10),"",ROW($B$3:$B$10)-MIN(ROW($B$3:$B$10))+1),ROW(A1))) and alike these formulas only allow the removal of blank lines from a single column. Whereas, I am attempting to achieve the same results but the removal of blank lines from columns across multiple rows.
EXAMPLE:
(A2) John Doe | (B2) New York | (C2) NY
(A3) BLANK | (B3) BLANK | (C3) BLANK
(A4) Jane Doe | (B4) Baltimore | (C4) MD
(A5) BLANK | (B5) BLANK | (C5) BLANK
(A6) Mary Jones | (B6) San Francisco | (C6) CA
(A7) BLANK | (B7) BLANK | (C7) BLANK
(A8) BLANK | (B8) BLANK | (C8) BLANK
(A9) William Jones | (B9) BLANK | (C9) IL
RESULTS:
(A2) John Doe | (B2) New York | (C2) NY
(A3) Jane Doe | (B3) Baltimore | (C3) MD
(A4) Mary Jones | (B4) San Francisco | (C4) CA
(A5) William Jones | (B5) BLANK | (C6) IL
This function should work:
{=IFERROR(INDEX($A$2:$C$10,MATCH(1,(COUNTIF($E$1:$E1,$A$2:$A$10)=0)*($A$2:$A$10>""),0),COLUMN(A1)),"")}
Note that this formula only works, if you don't have duplicates in column A. Also blank cells (like B5 in your example) will be filled with a 0. You can remove those by using a IF formula:
{=IFERROR(IF(INDEX($A$2:$C$10,MATCH(1,(COUNTIF($E$1:$E1,$A$2:$A$10)=0)*($A$2:$A$10>""),0),COLUMN(A1))>0,INDEX($A$2:$C$10,MATCH(1,(COUNTIF($E$1:$E1,$A$2:$A$10)=0)*($A$2:$A$10>""),0),COLUMN(A1)),""),"")}
Copy into E2 and drag down and then right. Don't forget to enter with CTRL + SHIFT + ENTER
Related
I have a table where each row represents one logical value.
Sort of like this:
| January | Margaret | 10 |
| February | Jeff | 20 |
| March | William | 30 |
I want to transfer the data to another table, where the data would be modelled as following:
| | January | February | March
+----------+---------+----------+------
| Margaret | 10 | |
| Jeff | | 20 |
| William | | | 30
In the case of changes in the Table 1 same changes should be reflected in the Table 2
There are only 4 names and 12 months. Names are repeated A,B,C,D,A,B,C,D,A,B,C,D.
Numbers are 10-120. Obviously I can use = and click on the cell in the first table but I need more optimal solution. I can't figure it out. Any advise would be much appreciated!
It sounds like what you're trying to do is called a long to wide transformation. In this case, since you just have months, it might be easiest to create a table with your months as headers (i.e. January - December), and then write a INDEX/MATCH formula to fill it in.
Let's say this is your table, starting in cell A2
Date Name Value
January Jone 1
January Mike 2
January Bob 3
February Jone 4
February Mike 5
February Bob 6
Then create a table with a header row for the months, starting in B10
January February March April May June July August September October November December
And a column for the unique names, starting in A11
Jone
Mike
Bob
So the whole thing looks like this:
January February March ...
Jone
Mike
Bob
Then we use an INDEX/MATCH formula to fill in the table. Write this in cell B11, then fill down and across:
=INDEX($C$3:$C$8,MATCH(1, INDEX(($A11=$B$3:$B$8)*(B$10=$A$3:$A$8),0,1),0))
This says, return a value from C3:C8 where both A11 and B10 match in their respective ranges B3:B8 and A3:A8.
You end up with:
January February ...
Jone 1 4
Mike 2 5
Bob 3 6
You can use Get&Transform to
Pivot Column 1
Advanced Options: Don't Aggregate
Values Column: Column 3
Is there a formula that can do the following:
Copy all the contents on column A, rows 1 to 4, into a new cell, and separate the contents using a new line.
Example input:
| A |
Row 1 | Alpha Beta Omega |
Row 2 | |
Row 3 | 21321 Cri Je |
Row 4 | Cappa NF B |
Example output:
Row 5 | Alpha Beta Omega
21321 Cri Je
Cappa NF B |
For Google sheets,
=JOIN(CHAR(10),FILTER(A1:A4,A1:A4<>""))
For Google sheets as well as Excel 2016 (w/Office365),
=TEXTJOIN(CHAR(10),1,A1:A4)
I want to be able to do this without the use of copy and paste, because there's way too many data on each, and would take hours or even days to finish. Here's an example of what I want to happen.
| Name | Street | Number |
John Blue RD 147
Red RD
George Yellow RD 543
PLUS
| Name | Street | Number |
Blue RD
Paul Red RD 352
Ringo 368
EQUALS
| Name | Street | Number |
John Blue RD 147
Paul Red RD 352
Ringo 368
George Yellow RD 543
And blank spaces are suppose to happen, thanks to anyone who has a solution to this, I've searched everywhere and couldn't find anything.
you can make a 3rd sheet in which each cell will be a function of the two.
For example, the A1 cell will contain:
=IF(ISNA(Sheet1!A1),Sheet2!A1,Sheet1!A1)
I'm looking to create an excel formula with 3 conditions.
Here's what I'm looking for:
D11 has a number (it is number of working hours). If the number is less than 4 (i.e. <=4), then I want it to show a value in cell B5,
If the number is between 4 and 8 (i.e. >4 and <=8), then I want it to show a value in cell B6.
If the number is over 8, then I want it to show a value in cell B7.
The cells in B5, B6 and B7 contain the relevant renimeration for 4-hours shift, 8-hours shift and for overtime.
This is what I have made:
IF(D11<4,"$B$5",IF(AND(D11>=4,E9<=8),"$B$6","$B$7")).
The Formula always gives a message :
"The formula you typed conains an error: - for information about fixing....;-to get assistance.....; - if you are not trying.......
Please advise!
I have tested and the follwoing is working for me:
=IF(B2<4,$E$2,IF(AND(B2>=4,B2<=8),$F$2,$G$2))
Here is the example of the data I was working with (replacing FORMULA with the above):
+-----+----------+----------+------------+-------------+-------------+-----------+--------+
| | A | B | C | D | E | F | G |
+-----+-----------------------------------------------------------------------------------+
| 1 | name | Overtime | Due | | | | |
+-----+-----------------------------------------------------------------------------------+
| 2 | bob | 4 | FORMULA | | 10 | 20 | 30 |
+-----+-----------------------------------------------------------------------------------+
Effectively if B2 is 4 then C2 should show 10.
Thank all of you. The problem was with the local settings that expect ; rather than , in Excel formulas.
Still I have problem with the formula, because I foud out that I should include one more condition: the case when the person is not working D11=0, because then he/she should receieve 0 or in the cell should be written a text "free day".
Consider the following (partial) Excel worksheet:
A | B | C | D
---+-------------+-------+-------
id | date | var_a | var_b
1 | 2011-03-12 | 200 | 34.22
1 | 2011-03-13 | 203 | 35.13
1 | 2011-03-14 | 205 | 34.14
1 | 2011-03-15 | 207 | 54.88
1 | 2011-03-16 | 208 | 12.01
1 | 2011-03-18 | 203 | 76.10
1 | 2011-03-19 | 210 | 14.86
1 | 2011-03-20 | 200 | 25.45
. | . | . | .
. | . | . | .
2 | 2011-03-12 | 200 | 34.22
2 | 2011-03-13 | 203 | 35.13
2 | 2011-03-14 | 205 | 34.14
2 | 2011-03-15 | 207 | 54.88
2 | 2011-03-16 | 208 | 12.01
2 | 2011-03-18 | 203 | 76.10
2 | 2011-03-19 | 210 | 14.86
2 | 2011-03-20 | 200 | 25.45
. | . | . | .
. | . | . | .
In reality, there are over 5.000 rows. I need to delete all rows which date falls on a saturday or sunday. In the example, March 12 and 13 (2011-03-12/13) and March 19 and 20 are Saturdays and Sundays. I cannot just delete every nth rows, since there might be days missing in the list (as is the case here with 2011-03-17).
Is this possible to do with either a formula or VBScript? I have never written a VBScript macro before (I have never had a use for it) so I would appreciate some help.
If you only need to do this once, this is what I would do. This should preserve the order, but if you're really worried about it, read very end of the post:
Add a new column, call it "Is Weekend". In it, put =if(WEEKDAY(B2, 2) > 5, 1, 0). Drag that formula down for the entire table.
Filter the columns. To do that, select the entire table (click on any table cell then hit Ctrl-A), then
On Excel 2007+, go to Data-> click "Filter"
On Excel 2003, go to Data->Filter->Auto Filter.
Sort everything by last column (Is Weekend) in descending order. This should put all weekend rows together without altering the order among the other rows.
Delete all rows with 1 in "Is Weeked" column. Delete that column.
If you're really worried about preserving order, before you do the above, you can do the following:
Add a new column called "Position". Put 1 in the first row, 2 in the second row, select them and drag it down to the bottom so every row has its own position number in increasing order.
Perform the filtering as above.
After you're done, sort everything in ascending order by "Position" column.
The trick is that you don't need to delete those rows, you need to replace their values for C and D with 0. This is easiest done with IF() and WEEKDAY() within two new columns C' and D' referencing C and D. Feel free to then just delete C and D.
You can do this in one go using an array formula. In cell E2, enter the following formula (on one line), and confirm with Ctrl-Shift-Enter (as opposed to the regular Enter)
=INDEX($A$2:$D$5000, SMALL(IF(WEEKDAY($B$2:$B$5000,2)>5, "",
ROW($B$2:$B$5000)-MIN(ROW($B$2:$B$5000))+1), ROW(A1)),COLUMN(A1))
5000 indicates the number of rows in your spreadsheet. After this, the formula should have curly braces around it to indicate it is an array formula. E2 should have the value 1. Then select cell E2 and drag the lower-right corner of the cell to the right until 4 cells are covered. Then drag the lower-right corner of the 4-cell-selection all the way down. At the bottom you will see rows containing #NUM!, one for each deleted row. You can delete those in the regular way.
In stead of starting off in cell E2, you could start off in cell A2 of a new sheet. In that case, you need to prepend the original sheet name to each reference in the formula, as in OriginalSheet!$A$2
This formula is an adaption from the one given in Excel: Remove blank cells
In case you decide to delete the rows, please make sure to run the VBA code from the last row to the first row. Here is a piece of code just written from memory to show you the idea of running from bottom to the top.
For i = Selection.Rows.Count To 1 Step -1
If WEEKDAY(Cells(r, 2),2) > 5 Then
Selection.Rows(i).EntireRow.Delete
End If
Next i