[Solved] Possible use of VLOOKUP

Discuss the spreadsheet application
Post Reply
User avatar
kenppy
Posts: 48
Joined: Tue Feb 10, 2015 7:28 pm

[Solved] Possible use of VLOOKUP

Post by kenppy »

I am making an assumption which may not be correct, but I couldn't get it to work.
The task is this:
1.I have a master sheet with col. BOX, essentially numbers 1 to 10,000 filtered ascending, not necessarily a full set.
2. For each BOX no. there is a corresponding cell NAME which will be filled by incoming data which for convenience will be on another sheet.
3. On both sheets I want to limit the range over which to act.In practice the blue box will most likely be longer.
4. Then for every line in "box" run through the lines in "BOX" and if numbers agree, place "name in "NAME".

Any thoughts?
Attachments
Screenshot 2024-07-12 at 15.24.08.png
Screenshot 2024-07-12 at 15.24.08.png (110.44 KiB) Viewed 4529 times
Last edited by Hagar Delest on Sat Jul 13, 2024 3:18 pm, edited 1 time in total.
Reason: tagged solved.
ApacheOpenOffice 4.1.7
Mac OsX 14.6.1
User avatar
MrProgrammer
Moderator
Posts: 5472
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Possible use of VLOOKUP

Post by MrProgrammer »

kenppy wrote: ↑Fri Jul 12, 2024 5:15 pm Then for every line in "box" run through the lines in "BOX" and if numbers agree, place "name in "NAME".
I don't see why you wouldn't be able to use VLOOKUP for that. This sounds exactly what VLOOKUP does when you use the technique in Q2/A2. The function can be used with ranges in different sheets.
[Tutorial] VLOOKUP questions and answers

kenppy wrote: ↑Fri Jul 12, 2024 5:15 pm On both sheets I want to limit the range over which to act.In practice the blue box will most likely be longer.
No one can help with that until you explain in detail how the spreadsheet will know what the ranges for the blue and red boxes are. If you need any additional assistance attach a spreadsheet demonstrating the difficulty (remove confidential information then use Post Reply, not Quick Reply, and don't attach a picture instead of the spreadsheet itself). I will not help further unless you attach.

kenppy wrote: ↑Fri Jul 12, 2024 5:15 pm I couldn't get it to work.
"It didn't work" isn't helpful in the forum because it tells us what did not happen. Please never use that phrase in a post. We need to know exactly what actions you took, what did happen, and what you expected to happen. For example, if you typed a formula, pressed Enter, and got #VALUE!, tell us that, not "It didn't work." Then attach your document so we can see what's wrong with that formula. Often "it didn't work" means "it didn't do what I expected" and the real problem is that the program is behaving correctly but your expectations are incorrect. To help you solve the problem we need to know your expectations and your ultimate goal.

If this solved your problem please go to your first post use the Edit ☐ button and add [Solved] to the start of the Subject field. Select the green checkmark icon at the same time.

[Tutorial] Ten concepts that every Calc user should know
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.7.8, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
User avatar
kenppy
Posts: 48
Joined: Tue Feb 10, 2015 7:28 pm

Re: Possible use of VLOOKUP

Post by kenppy »

Now that I know VLOOKUP is the correct entry point I will look up the help and examples.
Thanks for the quick response.
ApacheOpenOffice 4.1.7
Mac OsX 14.6.1
User avatar
keme
Volunteer
Posts: 3799
Joined: Wed Nov 28, 2007 10:27 am
Location: Egersund, Norway

Re: Possible use of VLOOKUP

Post by keme »

Note that VLooKUP() defaults to a kind of approximate matching and assumes that the key column is sorted. If there is no exact match, you will get the nearest lower value.
To force exact matching, you put zero in the fourth (optional) parameter to VLOOKUP(). No match will then return the #N/A error.
User avatar
kenppy
Posts: 48
Joined: Tue Feb 10, 2015 7:28 pm

Re: Possible use of VLOOKUP

Post by kenppy »

I've had partial success and wanted to show you a file but can't find a way to reduce 680 to 128 KB. Forgot how this is done!
ApacheOpenOffice 4.1.7
Mac OsX 14.6.1
User avatar
MrProgrammer
Moderator
Posts: 5472
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Possible use of VLOOKUP

Post by MrProgrammer »

kenppy wrote: ↑Fri Jul 12, 2024 5:15 pm I have a master sheet with col. BOX, essentially numbers 1 to 10,000 filtered ascending, not necessarily a full set.
kenppy wrote: ↑Fri Jul 12, 2024 9:59 pm I've had partial success and wanted to show you a file but can't find a way to reduce 680 to 128 KB. Forgot how this is done!
We don't need the entire file of 10000 rows, just enough to show what you're having difficulty with. A hundred rows is probably plenty. Close your spreadsheet. Open it again, use File → Save As → Name → VLOOKUP for Forum to make a copy, leaving the original untouched. Ensure that you are editing VLOOKUP for Forum. Delete the excess rows, save it, and attach that. You can also delete excess columns in the sheet or excess sheets which have no bearing on the problem. Ensure that the smaller file still demonstrates the difficulty. Explain which cell on which sheet of the reduced file contains a formula that doesn't do what you want. Explain in English what you want it to do.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.7.8, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
User avatar
kenppy
Posts: 48
Joined: Tue Feb 10, 2015 7:28 pm

Re: Possible use of VLOOKUP

Post by kenppy »

snip.ods
shows principle
(13.36 KiB) Downloaded 124 times
I know that there is still the issue with maintaining blank cells but the min thing is why did 'fred' H9 not transfer to the new list? The 'value to search for' and 'table to search in' will have a diffment number of lines.
ApacheOpenOffice 4.1.7
Mac OsX 14.6.1
User avatar
karolus
Volunteer
Posts: 1252
Joined: Sat Jul 02, 2011 9:47 am

Re: Possible use of VLOOKUP

Post by karolus »

Hallo

You start with Formula:

Code: Select all

=VLOOKUP( B10 ; $G4:$H9 ; 2 ;0 )
BUT YOU SHOULD start with:

Code: Select all

=VLOOKUP( B10 ; $G$4:$H$9 ; 2 ; 0 )
and for Libreoffice you may skip the #NA's with:

Code: Select all

=IFNA(VLOOKUP( B10 ; $G$4:$H$9 ; 2 ; 0 ); "" )
Libreoffice 25.2… on Debian 13 (trixie) (on RaspberryPI5)
Libreoffice 25.8… flatpak on Debian 13 (trixie) (on RaspberryPI5)
User avatar
kenppy
Posts: 48
Joined: Tue Feb 10, 2015 7:28 pm

Re: Possible use of VLOOKUP

Post by kenppy »

I don't understand, both of the last two codes give this:
Attachments
Screenshot 2024-07-13 at 08.29.43.png
Screenshot 2024-07-13 at 08.29.43.png (74.97 KiB) Viewed 4402 times
ApacheOpenOffice 4.1.7
Mac OsX 14.6.1
User avatar
robleyd
Moderator
Posts: 5528
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Possible use of VLOOKUP

Post by robleyd »

A sample spreadsheet would give some information; we can't tell anything from the picture as there is no information about what is in the formulae and where they are on the sheet.
Slackware 15 (current) 64 bit
Apache OpenOffice.1.16
LibreOffice 26.8.0.3; SlackBuild for 26.8.0 by Eric Hameleers
-----------
I hate this damn computer, I wish that I could sell it.
It won't do what I want it to, Only what I tell it.
User avatar
kenppy
Posts: 48
Joined: Tue Feb 10, 2015 7:28 pm

Re: Possible use of VLOOKUP

Post by kenppy »

I provided the file earlier in the thread, I thought I was replying to karolus who suggested a couple of solutions. Here it is again with the suggested code.
snip2.ods
(13.23 KiB) Downloaded 130 times
ApacheOpenOffice 4.1.7
Mac OsX 14.6.1
User avatar
karolus
Volunteer
Posts: 1252
Joined: Sat Jul 02, 2011 9:47 am

Re: Possible use of VLOOKUP

Post by karolus »

Hallo

If you may read my last post carefully, you should see that »IFNA« is only for LIBREOFFICE but not for AOO!
Libreoffice 25.2… on Debian 13 (trixie) (on RaspberryPI5)
Libreoffice 25.8… flatpak on Debian 13 (trixie) (on RaspberryPI5)
User avatar
robleyd
Moderator
Posts: 5528
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Possible use of VLOOKUP

Post by robleyd »

Your original upload didn't show this error; and without you showing the changed formula, it would have been a wild guessing game to determine the problem.
Slackware 15 (current) 64 bit
Apache OpenOffice.1.16
LibreOffice 26.8.0.3; SlackBuild for 26.8.0 by Eric Hameleers
-----------
I hate this damn computer, I wish that I could sell it.
It won't do what I want it to, Only what I tell it.
User avatar
kenppy
Posts: 48
Joined: Tue Feb 10, 2015 7:28 pm

Re: Possible use of VLOOKUP

Post by kenppy »

I think I've got the solution now by going through the tutorials!
Copies as expected and blanks left blank instead of #N/A.
snip3.ods
(13.94 KiB) Downloaded 123 times
ApacheOpenOffice 4.1.7
Mac OsX 14.6.1
Post Reply