Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

Input

1   0
7   77
6   66

Expected Output

7   66

Solution in Google Spreadsheet

= arrayformula(if(B2:C2,B3:C3,B4:C4))

How to do that in Excel?

Please, add label Spreadsheet -- the if clause is the same with Excel and Google Spreadsheet.

share|improve this question
And what is the question? Did you consult the manual? – mpiktas Oct 17 '11 at 11:40
Clarified question, trying to get the thing in Google Spreadsheet to work in Excel. – hhh Oct 17 '11 at 11:45
It is still NOT clear because you haven't written what this code is supposed to do; the easiest way to get 7 66 is just to write it ;-) – mbq Oct 17 '11 at 11:59
@mbq: thanks, good fix. – hhh Oct 17 '11 at 12:03

1 Answer

The labels on your rows and columns are missing, but I guess it's this:

$$ \begin{array}{c|r|r} & \mbox{B} & \mbox{C} \\ \hline 2 & 1 & 0 \\ 3 & 7 & 77 \\ 4 & 6 & 66 \\ \end{array} $$

For a given column, the if condition (if(B2:C2,B3:C3,B4:C4)) means: if the value in row 2 is true (or 1) then return the value at row 3 else return the value at row 4.

You can achieve this in Excel by typing (in B6, for example) =IF(B2,B3,B4), selecting B6:C6 and using "Fill right" (or by dragging the fill handle at the bottom right corner of the initial cell when expanding the selection).

share|improve this answer
...yeah well, I was looking a bit more elegant way, find this hard with large spreadsheets... – hhh Oct 17 '11 at 20:11
I guess to make it more convenient for a large range, you could type in the range in the name box in the formula bar and then choose "Fill right/down" from the menu. – Bruno Oct 17 '11 at 20:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.