Een oplossing met een macro (geen functie) voor Excelversies die 'Texjoin' nog niet kennen.
Die is uiteraard omslachtiger, maar daar heb je geen last van.
Aangenomen is dat de gegevens in rij 1 beginnen, in het eerste blad staan, en dat de eerste kolom bepalend is voor het aantal rijen waarvoor je de oplossing wil toepassen.
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| Sub macro1()
Dim x As Integer, y As Integer, lc As Integer
With Sheets(1)
x = 1
lc = .Cells(x, .Columns.Count).End(xlToLeft).Column
.Columns(lc).ClearContents
For x = 1 To .Cells(.Rows.Count, 1).End(xlUp).Row
lc = .Cells(x, .Columns.Count).End(xlToLeft).Column
.Cells(x, lc + 2).ClearContents
For y = 1 To lc
.Cells(x, lc + 2) = .Cells(x, lc + 2) & .Cells(x, y)
If y < lc Then .Cells(x, lc + 2) = .Cells(x, lc + 2) & ", "
Next y, x
With .Columns(lc + 2)
.HorizontalAlignment = xlLeft
.AutoFit
End With
End With
End Sub |
[
Voor 11% gewijzigd door
dix-neuf op 02-07-2024 17:52
]