Consider a table:
a b c d
key1 value1 value2 value3
key2 value1a value3a
i need to convert this into
Key1 Value1
Key1 Value2
Key1 Value3
Key2 Value1a
Key2
key2 Value3a
this code, works in putting all the data into a single column, including spaces as required, but i need to keep the first column as a key and I'm new to VBA in excel.
Sub MultiColsToA()
Dim rCell As Range
Dim lRows As Long
Dim lCols As Long
Dim lCol As Long
Dim ws As Worksheet
Dim wsNew As Worksheet
lCols = Columns.Count
lRows = Rows.Count
Set wsNew = Sheets.Add()
For Each ws In Worksheets
With ws
For Each rCell In .Range("B1", .Cells(1, lCols).End(xlToLeft))
.Range(rCell, .Cells(lRows, rCell.Column).End(xlUp)).Copy _
wsNew.Cells(lRows, 1).End(xlUp)(2, 1)
Next rCell
End With
Next ws
End Sub
The tables are approximately 55 rows with 12 to 30 columns. I ideally also need to convert 20 or so sheets in the same way, so a programmatic way of doing this would be ideal, can SO help?
Here is a basic example of how you could get something like that working. Hopefully this will be helpful as a concept and you can tweak to best suit what you're looking for: