1
OK...
So I have a list of products, with the product name like this: "CC973" in column A. i.e.:
A
CC969
CC972
CC973
CC975
CC976
CC977
CC978
CC996
CC997
CC998
CC999
DS009
DS022
DS046
DS088
DS096
I also have a list of product images like this in column A of another sheet "Image names'!$A$2:$A$617" (all the data is in that one column).:
A
CC967 CC968 CC969 (Packaging).jpg
CC967 CC968 CC969.jpg
CC972 CC973 (Packaging).jpg
CC972 CC973 (Rear).jpg
CC972 CC973.jpg
CC975 CC976.jpg
CC977 CC978 CC979 (Packaging).jpg
CC977 CC978 CC979.jpg
CC980 CC981 CC982 (Packaging).jpg
CC980 CC981 CC982 (Rear).jpg
CC980 CC981 CC982 (Side).jpg
What I would like to do is check for the product in the first list and return all the images that contain that product name separated by a "|".
I would like the file name with no extra text i.e. in the case just "CC972 CC973.jpg" to be returned first.
So in this example I would like the following to be returned:
CC972 CC973.jpg|CC972 CC973 (Packaging).jpg|CC972 CC973 (Rear).jpg
I'm sure this must be possible, can anyone advise a way to do that?
EDIT I have tried this:
=Lookup_concat(A2,'Image names'!$A$1:$A$617, 'Image names'!$A$1:$A$617)
But it returns #name?
I think to make this work I would have to use VBA with the following code:
Function Lookup_concat(Search_string As String, _
Search_in_col As Range, Return_val_col As Range)
Dim i As Long
Dim result As String
For i = 1 To Search_in_col.Count
If Search_in_col.Cells(i, 1) = Search_string Then
result = result & " " & Return_val_col.Cells(i, 1).Value
End If
Next
Lookup_concat = Trim(result)
End Function
however I don't think excel 2008 has a VBA editor!
I've not done spreadsheets properly since 2003!!!!
Do you want VBA or a formula? – Raystafarian – 2015-06-22T11:41:43.023
2
Welcome to Super User. Unfortunately, we are not a code-writing service. Instead of simply asking for code to perform a particular task, please show us what you've tried so far (including any code you currently have) and where you're stuck so that we can help you with your specific problem. Questions that only ask for code are too broad and are likely to be put on hold or closed.
– DavidPostill – 2015-06-22T11:42:44.623@Raystafarian I'm looking for a formula – Peter Kirkwood – 2015-06-22T11:55:30.390
@DavidPostill thanks you probably saw it's my first time here! I've put an edit in of what I have tried (but can't get yo work! Thanks for the advice! – Peter Kirkwood – 2015-06-22T11:57:14.053
@PeterKirkwood, This is now a good post. +1 and I will write some code for you. However, I need to know a bit more such as, where do you want the result to be? Column B of worksheet 2? – Dave – 2015-06-22T12:37:54.273
@Dave Great! Thanks Dave! Column C of Worksheet 3(called 'LMFD products') – Peter Kirkwood – 2015-06-22T13:09:13.450
Excel 2008 is a Mac version and has no VBA, updating tags accordingly – Julian Knight – 2015-06-22T13:19:00.147
Sorry Peter, I could only help if I could use VBa – Dave – 2015-06-22T20:31:02.200
@Dave I have managed to borrow a pc running excel 2013, so VBa is now an option too. Thanks. – Peter Kirkwood – 2015-06-23T08:06:15.473
@PeterKirkwood, sorry, wasn't on yesterday. Done – Dave – 2015-06-24T07:40:32.627