Pregunta

I have just about no experience messing around with formulas in Excel, but I'm trying to hack something together for someone who can't get their macros to work.

Essentially, I've done a sort list of a set of data, and need to grab the top four items. Using VLookup or Index seems to make the most sense, but the way the table is formatted (which for various reasons I can't change) it doesn't seem like I'll be able to get them to work (if I could switch the column/row definitions in them, then I could, but I'm not sure if I can/how). So anyway, I've got this long nested if statement I've thrown together that should do the trick, but it's throwing me a 509 error for a missing element. I've done just about everything I could think of to figure out what's going on, with no luck.

So here it is:

=IF(AO2=13, D2, IF(AP2=13, E2, IF(AQ2=13, F2, IF(AR2=13, G2, IF(AS2=13, H2, IF(AT2=13, I2, IF(AU2=13, J2, IF(AV2=13, K2, IF(AW2=13, L2, IF(AX1=13, M2, IF(AY2=13, N2, IF(AZ2=13, O2, IF(BA2=13, P2, "foo")))))))))))))

where the A02... values are the sort list (so index number 13 corresponds to the highest value in D2:P2) and the D2... is the corresponding value list I want it to return.

I was wondering if somebody could take a quick look and see if anything jumps out at them. I'm sure it's stupid and/or structural, but I can't get it working.

P.S. - I'm using Calc on a .xlsx file, but I'm pretty sure that should make no difference.

¿Fue útil?

Solución

The first thing I see is that your formula is referencing

IF(AX1=13, M2,

Where I'm sure you probably mean:

IF(AX2=13, M2,

But this can be made MUCH more efficient - One of the easiest ways to do this (and there are MANY) would be the SUMIF function. Given that only one value in AO2:BA2 will equal 13, you could write something like:

=SUMIF(AO2:BA2,13,D2:P2)

But, like I said, there are MANY ways you can get this solution - It depends on what you're trying to accomplish...

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top