
Gegevens in één cel splitsen en weergeven per cel. In Kolom A en B staan gegevens. Er staan telkens twee namen in één cel bijvoorbeeld in A2 . In B2 staan twee steden. Zie afbeelding.
1. Kopieer de onderstaande code middels Ctrl + C
2. Druk op de toetscombinatie ALT + F11 om de Visual Basic Editor te openen
3. Druk op de toetscombinatie ALT + N om het menu Invoegen te openen
4. Druk op M om een standaard module in te voegen
5. Daar waar de cursor knippert voeg je de code in middels Ctrl + V
6. Druk op de toetscombinatie ALT + Q om de Editor af te sluiten en terug te keren naar Excel
7. Druk op de toetscombinatie ALT + F8 om de Macro Dialoog te tonen. Dubbelklik op de macro naam om te starten
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
Sub Splitsen() Dim a As Variant, b As Variant, c As Variant Dim i As Long a = Range("A2", Range("B" & Rows.Count).End(xlUp)).Value ReDim b(1 To UBound(a) * 2, 1 To 2) For i = 1 To UBound(a) c = Split(a(i, 1), Chr(10)) b(i * 2 - 1, 1) = c(0) b(i * 2, 1) = c(1) c = Split(a(i, 2), Chr(10)) b(i * 2 - 1, 2) = c(0) b(i * 2, 2) = c(1) Next Range("D2:E2").Resize(UBound(b)).Value = b End Sub |