=HLOOKUP() works well in one situation with small table, but doesn't work in similar one with bigger table, why? (Need help)

StackOverflow https://stackoverflow.com/questions/22821510

  •  26-06-2023
  •  | 
  •  

Question

Here's an excerpt of my working file, where my problematic situation lies: Google Spreadsheet link

Right now I am balancing heroes and artifacts for my strategy game. I have two separate tables, one for heroes -- "(All) Heroes" sheet, and one for wearable artifacts -- "(All) Artifacts" sheet. Each hero can simultaneously wear 6 different artifacts and there are currently 26 of them in the game right now. I want to check how heroes' stats would change if they wear different combination of artifacts. In order to do that I need a separate sheet -- "(All) Heroes with Artifacts Calculator", where I can choose whichever hero of any level from my "Heroes sheet" and whichever combination of artifacts from my "Artifacts sheet". I also need a column, which will calculate the final stats of the chosen hero with all the chosen artifacts.

In order to do that I've decided to use data validation for hero/artifact picking (for example - cell '(All) Heroes with Artifacts Calculator!B2') and =HLOOKUP() function for table population according to the picked hero/artifact (for example - cell '(All) Heroes with Artifacts Calculator!B3'). The problem is, that my =HLOOKUP() formula in this case returns #N/A if sorting is set to false and an incorrect value if the sorting is set to true.

Before doing all this, I've created some small test tables for heroes, artifacts and resulting calculations: "Test Heroes", "Test Items" and "Test Calculator". The very same formula that gave #N/A in the first case works great in this one.

I really need to finish that big "(All) Heroes with Artifacts Calculator" table, but I don't know what to do. I've tried using =QUERY() function, but I wasn't able to achieve the desired result.

Please help me out.

Was it helpful?

Solution

Replace your formula =HLOOKUP($B$2,'(All) Heroes'!C:BT,2,false) with =HLOOKUP($B$2,'(All) Heroes'!C$4:BT,2,false)

Basically the first row of range should contain the key on which the lookup is done.

Edit

The above value will work for all attributes that are below the Row 4 in the "(All) Heros" sheet. For Level and Name (en_EN), you can use index and match.

For eg, the formula in cell (All) Heroes with Artifacts Calculator!B3 would be

=index('(All) Heroes'!C2:BT2, match(B$2,'(All) Heroes'!C$4:BT$4,0))

and that in cell (All) Heroes with Artifacts Calculator!B4 would be

=index('(All) Heroes'!C3:BT3, match(B$2,'(All) Heroes'!C$4:BT$4,0))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top