You can't just put that formula into a cell and hit enter as it will not work. You must array enter it, which means pressing CTRL+SHIFT+ENTER at the same time to enter it.
By the way. You could also have written the formula as per the following:-
=B2-INDEX(C2:F2,,MAX((C2:F2<>""

*TRANSPOSE(ROW(INDIRECT("1:4"

))))
The TRANSPOSE(ROW(INDIRECT("1:4"

)) might look a lot longer and unnecessary, and in this case it is, but imagine if you had a 100 cells to look at. Using ("1:100"

is easier than typing out 1 to 100 in an array constant.
Array formulas can be very powerful, and can cut down on the amount of formulas you need to put into your spreadsheet considerably. They can also look like magic sometimes
The most common example of this type of formula is from the SUMPRODUCT function, which although it doesn't need to be entered as an array, will nevertheless perform an array function.
Assume you have a series of values in A1:A20, and another series of values in B1:B20. You might want to multiply each set of values on each row and then sum them all up. Normally you would use a 3rd column with the formula =A1*B1, and then in C21 you would use =SUM(C1:C21) to add them all up. The power of an arry allows you to do this all in one cell. In any cell, simply put =SUMPRODUCT((A1:A20)*(B1:B20)) and it will add them all up for you without the need for the other column.
You can also do the same with a formula that ypou need to array enter, eg:-
=SUM((A1:A20)*(B1:B20)) array entered.
Just for the hell of it, take a look at the following if it is of interest:-
The following formula exploits the fact that Excel interprets TRUE as 1 and FALSE as 0. Take the formula below:-
=SUMPRODUCT((A9:A20=J1)*(B9:B20=J2)*(C9:C20))
This sets up an array that gives you something that looks like this (depending on the variables in J1 and J2 of course):-
A B C
9 TRUE * FALSE * 3
10 FALSE * FALSE * 4
11 TRUE * TRUE * 2
12 TRUE * TRUE * 1
13 TRUE * FALSE * 4
14 TRUE * TRUE * 3
15 TRUE * TRUE * 2
16 FALSE * TRUE * 8
17 TRUE * TRUE * 6
18 TRUE * TRUE * 8
19 TRUE * TRUE * 7
20 TRUE * TRUE * 6
Which because TRUE=1 and FALSE=0, is interpreted as:-
A B C
9 1 * 0 * 3 = 0
10 0 * 0 * 4 = 0
11 1 * 1 * 2 = 2
12 1 * 1 * 1 = 1
13 1 * 0 * 4 = 0
14 1 * 1 * 3 = 3
15 1 * 1 * 2 = 2
16 0 * 1 * 8 = 0
17 1 * 1 * 6 = 6
18 1 * 1 * 8 = 8
19 1 * 1 * 7 = 7
20 1 * 1 * 6 = 6
-------
35
and the SUM bit just adds up all the end values of the products
If you exclude the last part of the formula, so that it becomes:-
=SUMPRODUCT((A9:A20=A1)*(B9:B20="A"

)
then what you end up with is a sum of a bunch of TRUE/FALSE values depending on whether or not the criteria has been met on that row, and this is the same as counting the number of records that meet your criteria. Imagine the above tables without Column C, and the last one would look like the following:-
A B
9 1 * 0 = 0
10 0 * 0 = 0
11 1 * 1 = 1
12 1 * 1 = 1
13 1 * 0 = 0
14 1 * 1 = 1
15 1 * 1 = 1
16 0 * 1 = 0
17 1 * 1 = 1
18 1 * 1 = 1
19 1 * 1 = 1
20 1 * 1 = 1
-------
8
Hope I haven't bored you to sleep yet, only these really can be good fun when you get the hang of them.
Regards
Ken...................