[Solved] VLOOKUP Help

11 replies [Last post]
Gregm66
Offline
Last seen: 11 hours 36 min ago
Title: ★★★
Joined: 30 Apr 2016
Posts: 42
Hi Everyone,

I am using a vlookup formula to populate textboxes, my lookup function looks a cell then looks up the matching values on another sheet and returns those values to textboxes.

My question is, Is it at all possible to get the vlookup function to refer to 2 cells?

Below is the function i am using, it looks at K7 i also want it to look at K5.

=VLOOKUP(K7,$Recipes.B2:H80,4,Innocent

or is it possible to link a textbox to 2 different cells? IE: X4 and Z4

Thanks for any help in advance

mark_t
Offline
Last seen: 8 hours 17 min ago
Title: ★★★★
Joined: 26 Apr 2016
Posts: 90
You could create an index
You could create an index column, where Ax = Bx & Cx, then use =VLOOKUP ( X4 & Z4,$Recipes.A2:H80,5, 0 )

I’ve used this method in Excel, it should also work in LibreOffice.

It might be possible to use array formula, but I couldn’t get it to work.

Don’t forget to include spaces before and after parenthesis in posts or you start to see emoticons or sometimes missing text.

LibreOffice 5.1.3.2, Windows 8.1
Gregm66
Offline
Last seen: 11 hours 36 min ago
Title: ★★★
Joined: 30 Apr 2016
Posts: 42
thanks mark_t thankyou for
thanks mark_t

thankyou for your reply i have been playing with different ways for hours, can not get anything to work will show code below.

=VLOOKUP(K5&” “&K7,$Recipes.B2:H80,5,Innocent

thanks again for your reply mark_t

Gregm66
Offline
Last seen: 11 hours 36 min ago
Title: ★★★
Joined: 30 Apr 2016
Posts: 42
hi mark_t when you say
hi mark_t

when you say create an index column how do i do that?

sorry for the stupid question, i have not come across this before.

mark_t
Offline
Last seen: 8 hours 17 min ago
Title: ★★★★
Joined: 26 Apr 2016
Posts: 90
I meant add a new column at
I meant add a new column at beginning of the table, example column A, then in cell A2, enter the formula “=B2 & C2”, and copy this down the table in column A.

It seems the array formula was not working with the “AND” function, but I was able to get it working with:-


=INDEX ( $Recipes.$A$1:$G$100,MATCH ( 2, ( $A$1=$Recipes.$A$1:$A$100 ) +( $B$1=$Recipes.$B$1:$B$100 ) , 0 ), 4 )

This will search for the first row where both A1 is in column A of the Recipes sheet and B1 is in column B of the Recipes sheet, and return the value from column 4 of that row.

LibreOffice 5.1.3.2, Windows 8.1
Gregm66
Offline
Last seen: 11 hours 36 min ago
Title: ★★★
Joined: 30 Apr 2016
Posts: 42
Thanks mark_t i will put
Thanks mark_t

i will put this to the test.

sorry for the late reply back at work now.

thanks again for your help

Gregm66
Offline
Last seen: 11 hours 36 min ago
Title: ★★★
Joined: 30 Apr 2016
Posts: 42
Hi mark_t ok i put the
Hi mark_t

ok i put the formula in cell X20 and pressed ctrl, shift and enter.

but the only thing i get in my text box that i linked to X20 is a “0”

any ideas what i am doing wrong.
do i need to add the new column thing “=B2 & C2”

ok i took your code and changed it around abit, and it still doesn’t work see my code below.


=IF ( ISERROR(VLOOKUP(K7,$Recipes.B2:H80,4,0 )) , VLOOKUP(K5,$Recipes.B2:H80,4,0 ), VLOOKUP (K7,$Recipes.B2:H80,4,0 ))
Gregm66
Offline
Last seen: 11 hours 36 min ago
Title: ★★★
Joined: 30 Apr 2016
Posts: 42
It’s ok mark_t i figured it
It’s ok mark_t i figured it out it was simple really, using one of your suggestions.

I put “=K7 & K5” in cell X26
Then i used my VLOOKUP formula to look at X26, and it worked, now i can use my search feature or my other list option. See formula below.


=VLOOKUP ( X26,$Recipes.B2:H80,4,0 )

mark_t
Offline
Last seen: 8 hours 17 min ago
Title: ★★★★
Joined: 26 Apr 2016
Posts: 90
I’m not sure VLOOKUP does
I’m not sure VLOOKUP does what you think it does. I think it would only look in the first column for a match to the value in X26, so would only work if the first column is the combined value of the two columns you are trying to match.

I think the reason the text box did not work might be that you used ctrl-shift-enter, but you should not need ctrl-shift-enter for this expression as it returns only a single value. It should still work in a cell with or without ctrl-shift-enter, but it might stop the text box from picking up the value.

LibreOffice 5.1.3.2, Windows 8.1
Gregm66
Offline
Last seen: 11 hours 36 min ago
Title: ★★★
Joined: 30 Apr 2016
Posts: 42
Hi mark_t I am not sure
Hi mark_t

I am not sure what has gone wrong here, this works fine in my test book, I have transferred all the code etc to my actual workbook, and now the search is searching my ingredients. it only looks at the recipe name. any ideas I have attached my actual workbook.

The 2 white cells are the cells in question. the 2 green cells work perfectly fine.

my vlookup is located at X4 to X12, and x13 contains “=I4 & I3”

I cant see the vlookup being the problem as it functions perfectly well in the testbook.
For the correct results to be shown in the textboxes vlookup must look at cells I4 and I3
otherwise textboxes wont populate.

Thanks in advance

AttachmentSize
AOORecipeBook.5.3.ods 0 bytes
mark_t
Offline
Last seen: 8 hours 17 min ago
Title: ★★★★
Joined: 26 Apr 2016
Posts: 90
Did you see the PM?
Hi Greg, Not sure if you saw the PM but there is some problem with the last file you uploaded, shows 0 bytes and I can not download to take a look. If you could try and upload again and I can try again.
LibreOffice 5.1.3.2, Windows 8.1
Gregm66
Offline
Last seen: 11 hours 36 min ago
Title: ★★★
Joined: 30 Apr 2016
Posts: 42
Hi mark_t Sorry for the
Hi mark_t

Sorry for the late reply busy with work.

I looked over and over my workbook, and finally realised that I had a hidden column on the Recipes sheet, so I amended the code to search column 3 and it is working fine again now.

thanks again for your reply and all your help so far.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.