IdabaMalouki
New Member
- Joined
- Sep 10, 2024
- Messages
- 11
- Office Version
- 2021
- Platform
- Windows
I have a data set I copy and paste from a website. Someone helped me write a VBA code to sort the data:
Option Explicit
Can some help write a similar VBA for the new irregular data set in this excel workbook that will organize data in column A into format of adjacent columns:
Thanks in advance
Option Explicit
VBA Code:
Sub demo()
Dim a, b
Dim i As Long, j As Long, n As Long
a = [A1].CurrentRegion
ReDim b(1 To UBound(a, 1), 1 To 7)
For i = 2 To UBound(a, 1) Step 5
n = n + 1
b(n, 1) = a(i, 1): b(n, 2) = a(i + 2, 1): b(n + 1, 2) = a(i + 4, 1)
b(n, 3) = a(i, 2): b(n, 4) = a(i + 1, 2)
b(n, 5) = a(i, 3): b(n, 6) = a(i + 1, 3): b(n, 7) = a(i, 4)
n = n + 1
b(n, 3) = a(i + 3, 2): b(n, 4) = a(i + 4, 2)
b(n, 5) = a(i + 3, 3): b(n, 6) = a(i + 4, 3): b(n, 7) = a(i + 3, 4)
Next i
[N2].Resize(n, 7) = b
End Sub
Can some help write a similar VBA for the new irregular data set in this excel workbook that will organize data in column A into format of adjacent columns:
Thanks in advance
Last edited by a moderator: