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

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
it helps if you tell us what you are trying to do. It looks like for each id list all the .jpg files

[TABLE="width: 882"]
<colgroup><col span="2"><col><col span="7"></colgroup><tbody>[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]4658[/TD]
[TD]1000.jpg[/TD]
[TD]1000.jpg[/TD]
[TD]=b21[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]4658[/TD]
[TD]1001.jpg[/TD]
[TD]1000.jpg;1001.jpg[/TD]
[TD="colspan: 4"]=IF(A22=A21,C21&";"&B22,B22)[/TD]
[TD="colspan: 2"]drag this down[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]4658[/TD]
[TD]1002.jpg[/TD]
[TD]1000.jpg;1001.jpg;1002.jpg[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]4658[/TD]
[TD]1004.jpg[/TD]
[TD]1000.jpg;1001.jpg;1002.jpg;1004.jpg[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]4658[/TD]
[TD]1005.jpg[/TD]
[TD]1000.jpg;1001.jpg;1002.jpg;1004.jpg;1005.jpg[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]4703[/TD]
[TD]1024.jpg[/TD]
[TD]1024.jpg[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]4703[/TD]
[TD]1025.jpg[/TD]
[TD]1024.jpg;1025.jpg[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]4703[/TD]
[TD]1026.jpg[/TD]
[TD]1024.jpg;1025.jpg;1026.jpg[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]4913[/TD]
[TD]1031.jpg[/TD]
[TD]1031.jpg[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]4913[/TD]
[TD]1032.jpg[/TD]
[TD]1031.jpg;1032.jpg[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]4939[/TD]
[TD]1035.jpg[/TD]
[TD]1035.jpg[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]4939[/TD]
[TD]1036.jpg[/TD]
[TD]1035.jpg;1036.jpg[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]4939[/TD]
[TD]1037.jpg[/TD]
[TD]1035.jpg;1036.jpg;1037.jpg[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]4939[/TD]
[TD]1038.jpg[/TD]
[TD]1035.jpg;1036.jpg;1037.jpg;1038.jpg[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
UDF?

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


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
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,223,228
Messages
6,170,874
Members
452,363
Latest member
merico17

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