How to extract even cells from a column in excel? - excel-formula

I don't know how to exctract every second row to second column to have in result in this file https://mega.nz/#!18sAFAwC!YvRRS9zGQOvnVCwOS9KZXQtI7h7Bdle9RhTVdnFdqUE something like :
column1 ; column2
ab und zu ; od czasu do czasu
abbiegen ; skręcić
I'm playing with this for long time so I ask question. Thank for all responses

In B1, put the formula =IF(ISEVEN(ROW(A1)),A1,"")
This returns A1 if it's on an even row, else returns nothing. Copy the formula down. You should get values in even rows only.
Filter the B column to exclude empty cells, then just copy & paste the values shown.
If you have Excel 2010 or later, you could also do array formula.

Try this formula:
=IF(MOD(ROW(),2)=0,A1,"")
Multiply it from B1 to last nonempty cell and in column "B" will appear values only on odd rows.

Related

Concatenate cells within Excel row based off variable start and end columns

I have a dataset which looks like the following:
A
B
C
D
E
1
4
5
2
3
6
1
3
I need to create a column which concatenates the cells in each row from the first cell with a value, to the last cell with a value, even if there are blanks in the middle. These need to be separated by a semi-colon. So the output for the first row would be 1; ;4;5. Second row would be 2;3; ;6. Third row would be 1; ; ; ;3.
As it stands I have managed to add a couple of formulas which identify the start and end column references within the range for each row (i.e. first row starts column 1, ends column 4).
The formula for finding first non-blank cell ref in row:
={MATCH(FALSE(ISBLANK(H6:AB6),0)}
The formula for finding last non-blank cell ref in row:
=AGGREGATE(14,6,(COLUMN(H6:AB6)-COLUMN(H6+1)/(H6:AB6<>""),1)
I am struggling with how to get the formula to use the starting column number for that row and pull back subsequent cell values with the ; separator until it gets to and includes the last column reference number.
A FILTERXML() alternative:
Formula in G1:
=TEXTJOIN(";",0,IFERROR(FILTERXML("<t><s>"&TEXTJOIN("</s><s>",0,A1:E1)&"</s></t>","//s[.!='' or (following::*!='' and preceding::*!='')]"),""))
Use in J1 or Any of your Required Cell
=IF(AND(A1="",B1="",C1="",D1="",E1=""),"",CONCATENATE(A1,IF(AND(B1="",C1="",D1="",E1=""),".",IF(A1="",""," ;")),B1,IF(AND(C1="",D1="",E1=""),IF(AND(B1="",C1="",D1="",E1=""),"","."),IF(AND(A1="",B1=""),""," ;")),C1,IF(AND(D1="",E1=""),IF(AND(C1="",D1="",E1=""),"","."),IF(AND(A1="",B1="",C1=""),""," ;")),D1,IF(E1="",IF(AND(D1="",E1=""),"","."),IF(AND(A1="",B1="",C1="",D1=""),""," ;")),E1,IF(E1="","",IF(E1="","","."))))
Hope Thats what you actually want.
Just to answer the part of your question that asks about how to use the column number of first and last non-blank cell to get the result without leading and trailing semicolons, your formula would look like this:
=TEXTJOIN(";",0,INDEX(1:1,MATCH(FALSE,ISBLANK(A1:E1),0)):INDEX(1:1,AGGREGATE(14,6,(COLUMN(A1:E1)-COLUMN(A1)+1)/(A1:E1<>""),1)))
or shorter:
=TEXTJOIN(";",0,INDEX(1:1,MATCH(FALSE,ISBLANK(A1:E1),0)):INDEX(1:1,LOOKUP(2,1/(A1:E1<>""),COLUMN(A1:E1))))
The only advantage of using aggregate is that you don't need to array-enter it in earlier versions of Excel, but you don't need to array-enter the lookup formula either so I would tend to use that (and anyway in this case you probably need to array-enter the whole formula pre Excel-365).
This isn't too bad, but unfortunately if you wanted to make blanks into zeroes you would have to repeat most of the formula, unless you have Excel 365 and can use Let:
=TEXTJOIN(";",0,IF(INDEX(1:1,MATCH(FALSE,ISBLANK(A1:E1),0)):INDEX(1:1,LOOKUP(2,1/(A1:E1<>""),COLUMN(A1:E1)))="",0,
INDEX(1:1,MATCH(FALSE,ISBLANK(A1:E1),0)):INDEX(1:1,LOOKUP(2,1/(A1:E1<>""),COLUMN(A1:E1))) ))
If you have Excel 365, you can search from the end of the array using Xmatch:
=TEXTJOIN(";",0,INDEX(1:1,XMATCH(TRUE,A1:E1<>"")):INDEX(1:1,XMATCH(TRUE,A1:E1<>"",0,-1)))

How to compare cell against a set of cells and get an associated value

I need to compare the date of a cell against a column that has multiple date and I see which one it matches and get the associated value. Here I put an image to explain myself better:
Column D is where I need to put the formula, which compares the dates in column A on sheet 1 with the dates in column A on sheet 2. If it matches, I need to multiply the values in column C on sheet 1 by the values in column B of sheet 2.
Here another image with an example to be clearer
I have a little idea that would be something like:
= YES (ERROR (MATCH (Sheet1! A4; Sheet2! A2: A32; 0)); Sheet1! C4 * X
In the x it should go B3, but I don't know how to get that cell in the search above.
Try this:
=VLOOKUP(A3,sheet2!A:B,2)*C3
I have recreated your spreadsheets below.

How to refer to multiple adjacent cells

I have a work sheet in which there are several cells with a specific entry - let's say "A". These are not all in the same rows/columns. After each cell is a date.
I need to count the number of cells containing "A" which also have a specific date in the cell immediately to its right. I've tried combinations of Countifs and Indirect, with no success. How can I achieve this?
This counts the number of times that there is A in column A and 1 in column B
=SUMPRODUCT(($A$1:$A$5="A")*($B$1:$B$5=1))
This outputs in cell D1
Not too difficult.
I have created a sample sheet with 8 rows and 5 columns of data.
See below, the formula in cell C12 counts the number of occurrences where the a cell with a date of October 31, 2017 is directly to the right of a cell that contains the text A.
If you want more info as to how this works, read on:
When searching for cells that contain A, you don't search in the last column of the data (in this case, column E) because it is impossible for a column to the right to have any date in it. This is why a portion of the formula says A1:D8="A" instead of A1:E8="A". This is the same reasoning why we start searching for a date in column B rather than column A in the formula.
You can achieve this with a helper row. Add additional row on top of your Worksheet. In cell "A1" enter formula below.
=COUNTIFS(A2:A2000,"A",B2:B2000,"YourDate")
Drag this formula to the rightmost of where you have data, then simply sum all values returned by formula.

I have a stock list in excel

I have a stock list in excel. I'm using a formula =IF(E7=0,"-",D6+B7+C7-E7) which is fine as long as I enter a number in cell E7 but I need to get the calculation when I enter a value in B7 and/or C7. The formula is in cell D7 but I don't want formula results to be displayed in the cells below until there are more entries. Can you help please?
Instead of returning a dash, you could return an empty String. For example:
=IF(E7=0,"",D6+B7+C7-E7)
This will not display anything in a particular row in column D until there is a value in the corresponding row in column E.
I suggest you input an "Original Stock" column in B to account for the numers that don't add up in your example:
In that case, this formula should do the trick:
=IF(AND(B2=0,C2=0,D2=0,F2=0),"",B2+C2+D2-F2)
It checks to see if colums B and C and D and F are empty and outputs an empty cell if they are. Otherwise, you get the current stock from these cells.
Is this close to what you wanted to achieve?
You can download my test file
here

Excel get cells value if cells contain specific text

I have Table 1 & 2 like image.
How i can get all cells value if ID is equals?
If you just need to add numbers, there are formulas for this, but I'm not sure if there's a single formula for adding string values as in the provided example. One way to resolve this is by using accumulator columns as in this screen shot:
The formula in cell C3 is:
=IF($A3<>C$1,C2,IF(C2=0,$B3,C2&", "&$B3))
Copy this down to cell E10 (or wherever that table needs to end) and columns C to E will accumulate the values from column B. Table 2 then just maps the first and last rows of the accumulator columns. The zeros in cells C2 to E2 is a work-around to prevent Excel from converting blank cells into zeros.
Hope this helps!

Resources