Friday, January 13, 2012

Just Plain Wrong

After my rant of yesterday, I need to add one more I'm-being-an-idiot moment: I can, in fact, use VB. 


That'll teach me to look more closely at my error popup messages. Turns out that what I was trying to do before really wasn't allowed - I can't call up any popup messages - but a plain-Jane workaround for nested IF statements? Perfectly fine. 

Which brings me to the second half of yesterday, which was occupied with turning this: 

=CELL("address",INDEX(P94:W94,1,MATCH(MAX(P94,R94,T94,V94),P94:W94,0)))

into this: 

Or, in its full glory:  =IF(LEFT(CELL("address",INDEX(P94:W94,1,MATCH(MAX(P94,R94,T94,V94),P94:W94,0))),2)="$P","Your answer is in column P!",IF(LEFT(CELL("address",INDEX(P94:W94,1,MATCH(MAX(P94,R94,T94,V94),P94:W94,0))),2)="$R"," Your answer is in column R! ",IF(LEFT(CELL("address",INDEX(P94:W94,1,MATCH(MAX(P94,R94,T94,V94),P94:W94,0))),2)="$T"," Your answer is in column T! ",IF(LEFT(CELL("address",INDEX(P94:W94, 1,MATCH(MAX(P94,R94,T94,V94),P94:W94,0))),2)="$V", " Your answer is in column V! ","I haven't found a damn thing."))))   


This is actually a very simple formula - just big. It says, if you find the maximum value in this row in column P, tell me that I've found my first thing. If not, and it's really in column R, tell me I've found my second thing. If not, look in column T, and tell me if the maximum value is there. No? Look at column V. If it's there, let me know, and if not, we haven't found a damn thing. 

And it works, it does! Look:



This formula is very very very close to doing what I want it to do. From here, all I need to do is replace those bits of text that say "This is where I found the maximum!" with a little formula that pulls the value from the column one to the right of the one I just found. Something like:

$Q94

which isn't much of a formula at all, just a reference, but if I pop it in there, look what happens:







.....exactly what was supposed to happen. Goddamn, I hate Excel. 


ETA: After smashing a few keyboards and pettishly force-closing Excel, I wrapped the whole formula in a nice, cozy IF statement that says to only run through that whole monster of a formula if a maximum value really exists, and everybody was happy. Except me, because I hate Excel.


Also, the VBA point is moot, because I can work with just the formulas now.

No comments:

Post a Comment