Forum Discussion
syazaaoa95
Mar 08, 2023Brass Contributor
Organize my Data using Excel
Hi, I have a problem on how to organized my data. I want my data to become more clean. I think it should have like a way on how I'm going to do it with excel. This is the problem. I w...
HansVogelaar
Mar 08, 2023MVP
Run this macro:
Sub Rearrange()
Dim r As Long
Dim s As Long
Dim m As Long
Dim c As String
Application.ScreenUpdating = False
m = Range("A" & Rows.Count).End(xlUp).Row
ReDim v(1 To m, 1 To 2)
v(1, 1) = "Company"
v(1, 2) = "Category"
s = 1
For r = 2 To m
If Range("A" & r).IndentLevel = 0 Then
c = Range("A" & r).Value
Else
s = s + 1
v(s, 1) = c
v(s, 2) = Range("A" & r).Value
End If
Next r
Range("A1:B" & m).Value = v
Range("A1:A" & m).IndentLevel = 0
End Sub