"re-pivot"

lineto

New Member
Joined
Nov 9, 2007
Messages
9
Hi everyone,

I have a list formatted as follows (two columns):

A 2
B 1
C 4

and I want to convert this to this list (one column):

A
A
B
C
C
C
C

... any ideas?
Thanks in advance, lineto.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
How about this...

Code:
Sub OneCol()
    Dim LR As Long: LR = Range("A" & Rows.Count).End(xlUp).Row
    Dim LR1 As Long
    Dim i As Long

    For i = 1 To LR
        If Range("B" & i).Value > 1 Then
            LR1 = Range("A" & Rows.Count).End(xlUp).Offset(1).Row
            Range("A" & i).Copy _
                Range("A" & LR1).Resize(Range("B" & i).Value - 1)
        End If
    Next i
    Columns(2).Delete
    Range("A1:A" & Range("A" & Rows.Count).End(xlUp).Row).Sort _
    Key1:=Range("$A$1"), Order1:=xlAscending, Header:=xlGuess, _
    OrderCustom:=1, MatchCase:=False, _
    Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
End Sub
 
Upvote 0
Hi Jeffrey,
thanks a lot! I have forgot to say that I am using Excel 2008 on a Mac which isn't supporting Macros anymore -- are there any other possibilities to solve this problem?

Thanks, again!
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,729
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top