Selected Answer
Hello Leander,
The reason for your experience is that you are leaving column D blank. The code is based on there being numbers in that column.
There are several ways in which we could deal with the problem. One is to add numbers to colmn D automatically. Another is to delete column D entirely. I favour the latter because, as you found out, the numbers in column D can easily be replaced with Excel's own row numbers. But If I remove the column your instructions won't be correct anymore.
So I think the best way forward is for you to decide how you want to deal with column D.
- Add numbers there as you add phrases in columns E:F
- Have the program add missing numbers automatically (which may mess up "Blocked" numbers in some circumstances)
- Remove colmn D.
It's the curse of that index. This is what's happening:-
The code produces a number between 24 and the last used row in column D. Correct after the above corrections. It then retrieves the number in column D of the row it determined and writes that number to D13. Correct. Then your formula in E13 uses that number to retrieve the word using the formula =VLOOKUP(D13,D24:F4398,2). Wrong!
For one thing, the lookup range ends in row 4398 - far smaller than the actual determined by the code. For another, your formula returns an approximate value if it doesn't find an exact one. This is why it always returns the last value when the real value is not within range. To disable that feature the function should stipulate the match as "not approximate", resulting in ...
=VLOOKUP(D13,D24:F4398,2,False)
This corrected formula will fail to find a match (#N/A error) because the number you want isn't available in the defined range. Change the range definition and you are back in business.
EDIT 20 Jul 2021
Our project will benefit from your imput from now on. Therefore I attach the workbook on which I have been working these past 9 days.
After opening the workbook select "Teacher" as user and enter your birthday as 31 December 2020 (using the way your computer is set up to understand dates). This will give you access to the hidden worksheets which include, apart from the vocabulary itself, the tabs "Users", where you can see and set passwords (birthdays), "Help", where the system is explained, and "Methodology" where I wrote down some of the ideas I tried to implement. The user interface is designed to be intuitively usable but it will help you to read all I wrote.
It's a complicated project and I spent the last many hours on trouble-shooting. I discovered some flaws, which I fixed, but mostly just apparent flaws caused by lack of data. So, your part of the deal will be to convert your existing data into a system that my program is designed to work with. Then you may find real bugs which I shall be glad to fix once you describe their effect to me.
Good luck.