Ahah, dat is iets meer dan alleen een simpel formuletje... Ik zou voor een vba-scriptje gaan hier, al kan het vast ook wel met basic excel, maar als je alleen een hamer hebt, lijkt elk probleem op een spijker
Vooral niet gebruiken als je niet snapt wat de code doet!! het uitvoeren van vba heeft geen undo-knop!
Aanpassen naar je eigen wens:
Visual Basic:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
| Option Explicit
Sub HerhalenMaar()
Dim intHerhalingen As Integer
Dim strHerhalen As String
Dim c As Range
Dim rng As Range
Dim lonLaatsteRijA As Long
Dim lonLaatsteRijB As Long
Dim i As Long
With ActiveSheet
lonLaatsteRijA = .Cells(Rows.Count, "A").End(xlUp).Row
lonLaatsteRijB = .Cells(Rows.Count, "B").End(xlUp).Row
Set rng = .Range(.Cells(1, 1), .Cells(lonLaatsteRijA, 1))
End With
For Each c In rng
intHerhalingen = Mid(c.Value, InStrRev(c.Value, " ") + 1, Len(c.Value))
strHerhalen = Left(c.Value, InStrRev(c.Value, " ") - 1)
For i = 0 To intHerhalingen - 1
ActiveSheet.Cells(1, 2).Offset(lonLaatsteRijB + i, 0).Value = strHerhalen
Next i
lonLaatsteRijB = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row
Next c
End Sub |
levert:
[
Voor 4% gewijzigd door
breew op 15-11-2017 16:24
]