Author Topic: AToW Spreadsheet  (Read 21736 times)

Calan

  • Corporal
  • *
  • Posts: 54
Re: AToW Spreadsheet
« Reply #60 on: 21 December 2011, 04:00:11 »
This may take me a while to wrap my head around.  What exactly is the OFFSET returning to the expression?  And why the -1?

Offset takes a cell reference (e.g., $K$3) and moves you up/down a number of rows and/or left/right a number of columns you choose. So you lookup the ATT in your data table, find the index, and, starting at the first ATT level cell (Str), move down INDEX number of rows - 1 (so STR index 1 - 1 means don't move down at all).

You could start at the row above the Str Value, but if you later decide to insert a new row for some reason between the header and Str, it would mess up. You could also adjust the indexes to be 0-7, which would allow dropping the -1.

Edit: Actually, you can drop the step looking up the index by doing a VLOOKUP for exact match.

So this: LOOKUP(LOOKUP(LOOKUP(M28,'Data Tables'!E$15:E$22,'Data Tables'!F$15:F$22),D$3:D$10,K$3:K$10),'Data Tables'!M$15:M$25,'Data Tables'!N$15:N$25)

Becomes this: LOOKUP(VLOOKUP(M28,$E$3:$L$10,7,FALSE),'Data Tables'!M$15:M$25,'Data Tables'!N$15:N$25)

Making the following the new somewhat shorter expression:
=IF(LEFT(M28,3)=RIGHT(M28,3),LOOKUP(VLOOKUP(M28,$E$3:$L$10,7,FALSE),'Data Tables'!M$15:M$25,'Data Tables'!N$15:N$25),LOOKUP(VLOOKUP(LEFT(M28,3),$E$3:$L$10,7,FALSE),'Data Tables'!M$15:M$25,'Data Tables'!N$15:N$25)+LOOKUP(VLOOKUP(RIGHT(M28,3),$E$3:$L$10,7,FALSE),'Data Tables'!M$15:M$25,'Data Tables'!N$15:N$25))
« Last Edit: 21 December 2011, 04:11:17 by Calan »

Daryk

  • Lieutenant General
  • *
  • Posts: 37488
  • The Double Deuce II/II-σ
Re: AToW Spreadsheet
« Reply #61 on: 21 December 2011, 04:44:25 »
Ah, the FALSE flag in VLOOKUP is the key there.  It's been a while, but I wonder if that option was in Excel 2003 (where I was doing my original development).  Either that, or I didn't read far enough down in the function description to see it...

Calan

  • Corporal
  • *
  • Posts: 54
Re: AToW Spreadsheet
« Reply #62 on: 23 December 2011, 09:35:55 »
Making the following the new somewhat shorter expression:
=IF(LEFT(M28,3)=RIGHT(M28,3),LOOKUP(VLOOKUP(M28,$E$3:$L$10,7,FALSE),'Data Tables'!M$15:M$25,'Data Tables'!N$15:N$25),LOOKUP(VLOOKUP(LEFT(M28,3),$E$3:$L$10,7,FALSE),'Data Tables'!M$15:M$25,'Data Tables'!N$15:N$25)+LOOKUP(VLOOKUP(RIGHT(M28,3),$E$3:$L$10,7,FALSE),'Data Tables'!M$15:M$25,'Data Tables'!N$15:N$25))

I did that in Excel at work and just got around to pasting it into my sheet at home - apparently there're some syntax differences between Excel and OpenOffice Calc that cause a copy/paste of the above to fail.

To paste that into Calc and have it work, you'll need to first find-and-replace commas with semicolons and exclamation marks with periods.

Daryk

  • Lieutenant General
  • *
  • Posts: 37488
  • The Double Deuce II/II-σ
Re: AToW Spreadsheet
« Reply #63 on: 23 December 2011, 09:38:02 »
Odd... I didn't have to do any of that when I was moving the whole file back and forth.

Calan

  • Corporal
  • *
  • Posts: 54
Re: AToW Spreadsheet
« Reply #64 on: 23 December 2011, 12:43:44 »
Odd... I didn't have to do any of that when I was moving the whole file back and forth.

Yeah, they both seem to auto convert ok when opening the file, but copying/pasting expressions from one to the other doesn't. :-/

Or, since it'ssaved as an xls file, excel has no prob opening it, and Calc auto converts each time it opens it, and converts it back to Excel syntax on save.
« Last Edit: 23 December 2011, 12:45:46 by Calan »

Daryk

  • Lieutenant General
  • *
  • Posts: 37488
  • The Double Deuce II/II-σ
Re: AToW Spreadsheet
« Reply #65 on: 23 December 2011, 19:53:55 »
If that's what it's doing, I have to hand it to the Calc programmers.  The best code goes unnoticed.