Share via

Create list from header and string

Anonymous
2022-12-27T18:10:05+00:00

Looking for an vba/macro or formula resolution to create lists from headers and string underneath.

See example below:

Existing data is in columns... (B to D) with headers in first row.

Example shown below but range will be dynamic.

I need to create a list with all the headers and sentences aligned. in E and F.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

HansV 462.6K Reputation points
2022-12-27T19:31:45+00:00

Others will undoubtedly come up with a Microsoft 365 formula solution, or a Power Query solution. In the meantime, here is a short macro:

Sub StackData()
    Dim c As Long
    Dim s As Long
    Dim m As Long
    Dim t As Long
    Application.ScreenUpdating = False
    t = 2
    For c = 2 To 4
        m = Cells(Rows.Count, c).End(xlUp).Row - 1
        Cells(t, 6).Resize(m).Value = Cells(1, c).Value
        Cells(t, 7).Resize(m).Value = Cells(2, c).Resize(m).Value
        t = t + m
    Next c
    Application.ScreenUpdating = True
End Sub

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Ashish Mathur 102K Reputation points Volunteer Moderator
    2022-12-27T23:10:49+00:00

    Hi,

    In the Query Editor, create an Index column. Right click on the Index column and select "Unpivot Other Columns". Rename the columns. Click on Close and Load.

    Hope this helps.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2022-12-27T20:42:19+00:00

    This works just fine.

    Thanks again!

    ...add another Krystal burger!

    Was this answer helpful?

    0 comments No comments