HLOOKUP returns #N/A, but the value is there

Alonshow

New Member
Joined
May 29, 2023
Messages
5
Office Version
  1. 2021
Platform
  1. Windows
Hi, I'm struggling with some formulas that use HLOOKUP to retrieve values from a table. I have checked that the reference values I give to HLOOKUP are correct, and that those values are present in the data table, but my formulas return #N/A even though everything seems to be correct.

Context: I believe this is an unusual case scenario for Excel. I have some mental health problems that heavily affect my day-to-day routine, and I use an Excel workbook to monitor my daily activity and assess whether I am making progress. The core of the workbook is a set of formulas that read data about my activity during the day and return a number that tells me how good/bad that day was. For instance, I want to follow about a dozen healthy daily habits every day (like eating vegs, taking my medication, doing some exercise, etc). One of the formulas counts how many of these I follow each day. If I run that formula for yesterday and the result is 11, that means that yesterday I was very consistent with my daily habits. If I get 5 it means there's room for improvement. And if I get 1 it means it was a disaster.

This particular formula looks like this:
=IF(ISNUMBER(Day_1), HLOOKUP(Day_1,Activities_2022B,19,FALSE), "")

This formula refers to the table Activities_2022B, which contains a list of my healthy habits for each day of the year. Row 19 of that table is a sum of the number of daily habits I have performed in a particular day.

These formulas have been working well for several years. However, one month ago I decided to do a bit of clean-up of the workbook because it had been growing so much that it was starting to be difficult to manage. As part of the clean-up, I used the Name manager to remove tables that didn't seem to be in use, and also to rename tables that are in use to make their names more consistent. At first, it seemed to work well, but the next time I tried to put the worksheet to actual use, lots of #N/A errors started to show up all over the place.

Now, when I try to rename the tables in the sheet, I get some weird error messages. For instance, if I try to rename the table Activities_2022B to Activities_2022 (without the B), Excel says that's not possible because there is another table called Activities_2022. However, that other table doesn't show up in the Name Manager or anywhere else.

I attach the range where my data is located, which is a part of the Activities_2022B table (the whole table is too big to post here).

Forum sample.xlsx
LYLZMAMBMCMDMEMFMGMHMIMJMKMLMMMNMOMPMQMRMSMTMUMVMWMXMYMZNANBNC
1Thu, 01-DecFri, 02-DecSat, 03-DecSun, 04-DecMon, 05-DecTue, 06-DecWed, 07-DecThu, 08-DecFri, 09-DecSat, 10-DecSun, 11-DecMon, 12-DecTue, 13-DecWed, 14-DecThu, 15-DecFri, 16-DecSat, 17-DecSun, 18-DecMon, 19-DecTue, 20-DecWed, 21-DecThu, 22-DecFri, 23-DecSat, 24-DecSun, 25-DecMon, 26-DecTue, 27-DecWed, 28-DecThu, 29-DecFri, 30-DecSat, 31-Dec
25 PM11 PM10 PM1 AM2 AM3 AM5 AM2 AM3 AM4 AM5 AM6 AM7 AM8 AM1 PM12 PM12 PM12 PM3 PM4 PM3 PM5 AM5 AM4 AM3 PM2 AM4 AM1 AM
34 PM4 PM5 PM6 PM10 PM8 PM4 PM5 PM8 PM10 PM11 PM10 PM10 PM6 AM5 AM3 AM3 AM7 AM11 AM7 AM12 AM11 PM11 PM5 AM3 PM7 PM5 PM3 PM
4876088591010877910770998585651001198
5xxxxxxxxxxxxxxxxxxx
6x
7xxxxxxxxxxxxxxxxx
8xxxxxxxxxxxxxxxxx
9xxxxxxxxxxxxxxxxxxxxxxxxxxx
10xx
11WalkingWalking
12
13
14xxxxxxxxxx
15MelanieMónicaMerceLang exchMerce
16MelanieJáledFundación AnarMerceLang exchMerce
18xxxxxxxxxxxxxxxxxxxxxxxx
1993415554922222835 255838355 555
21
22MónicaLang exch
23JáledMerceLang exchMerce
24
25xxxx
26MelanieMerceMerce
27
28Mónica
29-2  1    -2     -1      3 -100     
Routine tasks 2022
Cell Formulas
RangeFormula
LY4:NC4LY4=HOUR(IF(AND(ISNUMBER(LY2), ISNUMBER(LX3)), IF(LY2>LX3,LY2-LX3, (1+LY2)-LX3), IF(ISNUMBER(LY2),IF(LY2>LW3,LY2-LW3, (1+LY2)-LW3), 0)))
LY19:NC19LY19=IF(COUNTA(LY5:LY18)>0, COUNTA(LY5:LY18),"")
LY29:NC29LY29=IF(COUNTA(LY21:LY28)=0, "", 2*COUNTA(LY21) + 2*COUNTA(LY22) + COUNTA(LY23) - 2*COUNTA(LY26) - 3*COUNTA(LY27) - 4*COUNTA(LY28) + IF(COUNTA(LY24)=0, 0, 8-LY4))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B4:XFD4Cell Value=0textNO
C4:NC4Cell Valuebetween 11 and 500textNO


Thank you in advance for any help.
 
A structured table is a range of cells declared to be an entity with some internal organization. For example, table Headers can be used to refers to the table column datas.
When you create a Table (Menu /Insert /Table) the table is assigned a name, that is also a named range visible via the Formula /Name manager; you cannot modify the “Refers to” box

For how to Create and format tables:

For how the elements in a table can be addressed:

If your range turned to be a structured table, then if you go to a free cell, type = (to start a formula) then with the mouse you click on C1 (to insert the formula =C1) then the formula you see in the formula bar should look like =TableName[[#Headers],[HeaderValue]]
Also if you select any cell in the area then in the ribbon a new tab should be displayed, named “Table Structure” (or something similar)

Some of your symptoms tell me that your range might be a structured table; but such a table should have peculiar formatting elements that I don’t see

Maybe by having access to your real workbook we could go to the source of the problem; at the moment I am afraid we have to settle for the Offset solution.
I should however suggest that you recreate your workbook from scratch, moving the data from your current file to the new one using Copy / Paste special – Values only; at that point the confusion that is in your current workbook should have gone away
 
Upvote 0

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top