Vlookup across multiple values to return only one
Closed
SpaceMonkees
Posts
7
Registration date
Wednesday July 31, 2013
Status
Member
Last seen
December 2, 2013
-
Nov 28, 2013 at 11:53 AM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Dec 2, 2013 at 10:15 PM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Dec 2, 2013 at 10:15 PM
Related:
- Vlookup across multiple values to return only one
- Display two columns in data validation list but return only one - Guide
- How to delete multiple files on mac - Guide
- How to lasso multiple objects in photoshop - Guide
- Allow multiple downloads chrome - Guide
- Zuma return - Download - Puzzle
4 responses
venkat1926
Posts
1863
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
August 7, 2021
811
Nov 30, 2013 at 01:06 AM
Nov 30, 2013 at 01:06 AM
I am not using vlookup
I use a macro and find function. run the macro and see column G
still I am not clear why is coloumn K
I use a macro and find function. run the macro and see column G
still I am not clear why is coloumn K
Sub test()
Dim j As Integer, k As Integer
Dim r As Range, r2 As Range, cfind As Range
Dim x As String, m As Integer, y As String
j = Range("A3").End(xlDown).Row
Range(Range("G2"), Cells(j, "G")).Cells.Delete
Set r = Range(Range("a2"), Range("a2").End(xlToRight).End(xlDown))
'msgbox r.Address
Set r2 = Range(Range("H11"), Range("H11").End(xlToRight).End(xlDown))
'msgbox r2.Address
For k = 3 To j
For m = 4 To 6
x = Cells(k, m)
x = StrConv(x, vbUpperCase)
'msgbox x
Set cfind = r2.Find(what:=x, lookat:=xlWhole)
If Not cfind Is Nothing Then
'msgbox cfind.Address
y = Cells(cfind.Row, "J")
'msgbox y
GoTo nextstep
Else: GoTo nextm
End If
nextstep:
Cells(k, "G") = y
GoTo nextk
nextm:
Next m
nextk:
Next k
MsgBox "macro over"
End Sub
venkat1926
Posts
1863
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
August 7, 2021
811
Nov 29, 2013 at 12:24 AM
Nov 29, 2013 at 12:24 AM
I am confused. the problem is with translating thoughts into text. It happened to me also sometimes.
D1 E1 F1 are not data but merged cells and headings
D2 E2 F2 are also not data but invdiviual column headings.
Perhpas you are thinking from row no. 3
your selection is E3 D4 and F5
ok these data are available in the second table. They are red colored
then what?
you mean corresponding to the red selection in main table, do you want vlookp of (is it third column or fourth column of second table. perhaps it is possible to refer to red marked data in the first sheet for each row as reference cell for vlookup and ref table being second table
for e.g. for first red nk69772.correspoding scanned numbers are are in B3 and C3. then what??
some more clarifications will be helpful.
D1 E1 F1 are not data but merged cells and headings
D2 E2 F2 are also not data but invdiviual column headings.
Perhpas you are thinking from row no. 3
your selection is E3 D4 and F5
ok these data are available in the second table. They are red colored
then what?
you mean corresponding to the red selection in main table, do you want vlookp of (is it third column or fourth column of second table. perhaps it is possible to refer to red marked data in the first sheet for each row as reference cell for vlookup and ref table being second table
for e.g. for first red nk69772.correspoding scanned numbers are are in B3 and C3. then what??
some more clarifications will be helpful.
SpaceMonkees
Posts
7
Registration date
Wednesday July 31, 2013
Status
Member
Last seen
December 2, 2013
Nov 29, 2013 at 07:22 AM
Nov 29, 2013 at 07:22 AM
Thanks venkat - I thought I would complicate it. And the sample file cells don't relate to the ones I put in the original post - the sample file was an after thought pulled from my existing data set which I can see how it confused the situation even more so apologies! :D
However, lets take the sample file and ill try and clarify.
I want G3 to look at the values in D3, E3 & F4 and compare them to everything in column H. If it finds a match (which it will do in H15), I want it to display the contents of I15, J15 & K15. Actually for the purposes of this, lets just say I want G3 to show J15 as I can fiddle with it to show the description & status etc later.
The reason column D,E & F exist is because the scanned part codes (column B & C) have various formats so my thought was that i have to extract the right numbers from the part codes and this had to be done in separate cells. Then with the three variations of possible correct parts, thats when it does a lookup etc
i can do vlookups no problem - what i cant do is look up three different values from three different cells, knowing that one of the three will be the right one.
Clear as mud?! :D
However, lets take the sample file and ill try and clarify.
I want G3 to look at the values in D3, E3 & F4 and compare them to everything in column H. If it finds a match (which it will do in H15), I want it to display the contents of I15, J15 & K15. Actually for the purposes of this, lets just say I want G3 to show J15 as I can fiddle with it to show the description & status etc later.
The reason column D,E & F exist is because the scanned part codes (column B & C) have various formats so my thought was that i have to extract the right numbers from the part codes and this had to be done in separate cells. Then with the three variations of possible correct parts, thats when it does a lookup etc
i can do vlookups no problem - what i cant do is look up three different values from three different cells, knowing that one of the three will be the right one.
Clear as mud?! :D
SpaceMonkees
Posts
7
Registration date
Wednesday July 31, 2013
Status
Member
Last seen
December 2, 2013
Dec 2, 2013 at 08:09 AM
Dec 2, 2013 at 08:09 AM
That works great!
However I dont think it is going to be ideal for the main project due to my lack of up to date VB knowledge and the need for simplicity for the contractors. It works, but I would be limited in amending it.
how would I extend this to cover more rows covering columns B-F? IE the part code list could be 200 lines long so i need to ensure the macro runs for all part codes in column B&C.
And what would happen if another part code variation appears? Can I insert a new column in between F & G?
And tradtiionally, my lookup data is on another workbook. What code would be needed here?
I really do appreciate what you have done and you have provided an answer to exactly what was needed... I just need to expand on it and change it from the test document into the main sheet.
I will have a play about with it and change some of the code and see if it works. Its been 15 years since I last used VB!! :D
However I dont think it is going to be ideal for the main project due to my lack of up to date VB knowledge and the need for simplicity for the contractors. It works, but I would be limited in amending it.
how would I extend this to cover more rows covering columns B-F? IE the part code list could be 200 lines long so i need to ensure the macro runs for all part codes in column B&C.
And what would happen if another part code variation appears? Can I insert a new column in between F & G?
And tradtiionally, my lookup data is on another workbook. What code would be needed here?
I really do appreciate what you have done and you have provided an answer to exactly what was needed... I just need to expand on it and change it from the test document into the main sheet.
I will have a play about with it and change some of the code and see if it works. Its been 15 years since I last used VB!! :D
venkat1926
Posts
1863
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
August 7, 2021
811
Dec 2, 2013 at 10:15 PM
Dec 2, 2013 at 10:15 PM
I have used end(xltoright) and end(xldown). I suppose it will work even if more rows and columns to be added. anyhow it has to be checked and macro debugged and modified if necessary. test it on your extended data (KEEP THE DATA FILE SAFELY SOMEWHERE) AND GIVE FEEDBACK.