Need to edit code to work with this spreadsheet please.

SOLTEC

Board Regular
Joined
Feb 11, 2015
Messages
195
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Sub ConcatImageGroups()
Dim LastRow As Long, Ar As Range
LastRow = Cells(Rows.Count, "M").End(xlUp).Row
Range("O2:O" & LastRow) = Evaluate("IF(M2:M" & LastRow & "=1,1,"""")")
For Each Ar In Range("O2:O" & LastRow).SpecialCells(xlBlanks).Areas
Ar(1).Offset(-1).Resize(Ar.Count + 1) = Join(Application.Transpose(Ar(1). _
Offset(-1, 1).Resize(Ar.Count + 1)), ";")
Next
End Sub


Excel 2010
ABC
1IDImagesCombination Images
246581000.jpg1000.jpg;1001.jpg;1002.jpg;1003.jpg;1004.jpg;1005.jpg;
346581001.jpg1000.jpg;1001.jpg;1002.jpg;1003.jpg;1004.jpg;1005.jpg;
446581002.jpg1000.jpg;1001.jpg;1002.jpg;1003.jpg;1004.jpg;1005.jpg;
546581004.jpg1000.jpg;1001.jpg;1002.jpg;1003.jpg;1004.jpg;1005.jpg;
646581005.jpg1000.jpg;1001.jpg;1002.jpg;1003.jpg;1004.jpg;1005.jpg;
747031024.jpg1024.jpg;1025.jpg;1026.jpg;
847031025.jpg1024.jpg;1025.jpg;1026.jpg;
947031026.jpg1024.jpg;1025.jpg;1026.jpg;
1049131031.jpg
1149131032.jpg
1249391035.jpg
1349391036.jpg
1449391037.jpg
1549391038.jpg
1650471045.jpg
1750471046.jpg
1850471047.jpg
1950471048.jpg
2050791051.jpg
2150791057.jpg
2250791058.jpg
2350791059.jpg
2451351060.jpg
2551351061.jpg
2651351062.jpg
2751351063.jpg
2851351064.jpg
2951351065.jpg
3051351066.jpg
3151351067.jpg
3251351070.jpg
3351351071.jpg
3451351072.jpg
3551351073.jpg
3651351074.jpg
3751351079.jpg
Sheet5


Thank you in advance for all assistance. It is greatly appreciated.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
it helps if you tell us what you are trying to do. It looks like for each id list all the .jpg files

46581000.jpg1000.jpg=b21
46581001.jpg1000.jpg;1001.jpg=IF(A22=A21,C21&";"&B22,B22)drag this down
46581002.jpg1000.jpg;1001.jpg;1002.jpg
46581004.jpg1000.jpg;1001.jpg;1002.jpg;1004.jpg
46581005.jpg1000.jpg;1001.jpg;1002.jpg;1004.jpg;1005.jpg
47031024.jpg1024.jpg
47031025.jpg1024.jpg;1025.jpg
47031026.jpg1024.jpg;1025.jpg;1026.jpg
49131031.jpg1031.jpg
49131032.jpg1031.jpg;1032.jpg
49391035.jpg1035.jpg
49391036.jpg1035.jpg;1036.jpg
49391037.jpg1035.jpg;1036.jpg;1037.jpg
49391038.jpg1035.jpg;1036.jpg;1037.jpg;1038.jpg

<colgroup><col span="2"><col><col span="7"></colgroup><tbody>
</tbody>
 
Upvote 0
UDF?

Row\Col
A​
B​
C​
D​
1​
ID
Images
Combination Images
2​
4658​
1000.jpg1000.jpg; 1001.jpg; 1002.jpg; 1004.jpg; 1005.jpgC2: =CatIf(INDEX($A$2:$A$37=A2, 0), $B$2:$B$37, "; ")
3​
4658​
1001.jpg1000.jpg; 1001.jpg; 1002.jpg; 1004.jpg; 1005.jpg
4​
4658​
1002.jpg1000.jpg; 1001.jpg; 1002.jpg; 1004.jpg; 1005.jpg
5​
4658​
1004.jpg1000.jpg; 1001.jpg; 1002.jpg; 1004.jpg; 1005.jpg
6​
4658​
1005.jpg1000.jpg; 1001.jpg; 1002.jpg; 1004.jpg; 1005.jpg
7​
4703​
1024.jpg1024.jpg; 1025.jpg; 1026.jpg
8​
4703​
1025.jpg1024.jpg; 1025.jpg; 1026.jpg
9​
4703​
1026.jpg1024.jpg; 1025.jpg; 1026.jpg
10​
4913​
1031.jpg1031.jpg; 1032.jpg
11​
4913​
1032.jpg1031.jpg; 1032.jpg
12​
4939​
1035.jpg1035.jpg; 1036.jpg; 1037.jpg; 1038.jpg
13​
4939​
1036.jpg1035.jpg; 1036.jpg; 1037.jpg; 1038.jpg
14​
4939​
1037.jpg1035.jpg; 1036.jpg; 1037.jpg; 1038.jpg
15​
4939​
1038.jpg1035.jpg; 1036.jpg; 1037.jpg; 1038.jpg
16​
5047​
1045.jpg1045.jpg; 1046.jpg; 1047.jpg; 1048.jpg
17​
5047​
1046.jpg1045.jpg; 1046.jpg; 1047.jpg; 1048.jpg
18​
5047​
1047.jpg1045.jpg; 1046.jpg; 1047.jpg; 1048.jpg
19​
5047​
1048.jpg1045.jpg; 1046.jpg; 1047.jpg; 1048.jpg
20​
5079​
1051.jpg1051.jpg; 1057.jpg; 1058.jpg; 1059.jpg
21​
5079​
1057.jpg1051.jpg; 1057.jpg; 1058.jpg; 1059.jpg
22​
5079​
1058.jpg1051.jpg; 1057.jpg; 1058.jpg; 1059.jpg
23​
5079​
1059.jpg1051.jpg; 1057.jpg; 1058.jpg; 1059.jpg

Code:
Function CatIf(avbIf As Variant, _
               rInp As Range, _
               Optional sSep As String = ",", _
               Optional bCatEmpty As Boolean = False) As String
  ' shg 2007
  ' UDF only

  ' Catenates the elements of rInp separated by sSep where the corresponding
  ' element of avbIf is True. Empty cells ignored unless bCatEmpty is True.

  Dim iRow          As Long
  Dim iCol          As Long
  Dim i             As Long

  On Error Resume Next
  i = UBound(avbIf, 2)

  If Err.Number Then
    ' avbIf is 1D
    For iRow = 1 To rInp.Rows.Count
      For iCol = 1 To rInp.Columns.Count
        i = i + 1
        If avbIf(i) Then
          If bCatEmpty Or Not IsEmpty(rInp(iRow, iCol).Value2) Then
            CatIf = CatIf & rInp(iRow, iCol).Value2 & sSep
          End If
        End If
      Next iCol
    Next iRow
  Else
    ' it's 2D
    For iRow = 1 To rInp.Rows.Count
      For iCol = 1 To rInp.Columns.Count
        If avbIf(iRow, iCol) Then
          If bCatEmpty Or Not IsEmpty(rInp(iRow, iCol).Value2) Then
            CatIf = CatIf & rInp(iRow, iCol).Value2 & sSep
          End If
        End If
      Next iCol
    Next iRow
  End If

  If Len(CatIf) Then CatIf = Left(CatIf, Len(CatIf) - Len(sSep))
End Function
 
Upvote 0
Each product has multiple images (.jpg) files that need to associated with that product. What this does is gives me all the product combination images. Red shirt, blue shirt, grey shirt, etc..
 
Upvote 0
I need all the .jpg files in all matching numbers, not concatenated each time OldBrewer please
 
Upvote 0
Please pardon me. I had three strokes in 2013 and I'm not the sharpest tool in the shed. How do I use your UDF Function please?
 
Upvote 0
1. Copy the code from the post.

2. In Excel, do Alt + F11 to open the Visual Basic Editor.

3. From there, Insert > Module, and paste the code in the window that opens.

4. Do Alt+Q to return to Excel, and enter the formula as shown.

Then, VERY IMPORTANT, save the workbook with an xlsm extension.
 
Upvote 0
with my approach easy to find last id number (with max number of jpegs) and copy to new location and repeat for all ids
 
Upvote 0
I like oldbrewer's approach.
 
Upvote 0
shg - in fact if say cell D3 has the max number of jpegs, a formula in say D100 should be able to find the ID (in C100) that is last in its block and bring back the jpeg string, probably using offset match.............
 
Upvote 0

Forum statistics

Threads
1,215,781
Messages
6,126,870
Members
449,345
Latest member
CharlieDP

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top