|
こんなコードで、どうかな ?
Sub MyAlign()
Dim LR As Long
Dim C As Range
Dim St As String
Dim Ary As Variant
LR = Range("B65536").End(xlUp).Row
For Each C In Range("C1:D" & LR)
St = St & C.Value & ","
Next
Ary = WorksheetFunction.Transpose(Split(St, ","))
Application.ScreenUpdating = False
Range("C1:D" & LR).ClearContents
Range("C1").Value = 1
Range("C1:C" & LR).DataSeries xlColumns, , , 2
With Range("C" & LR + 1)
.Value = 2
.Resize(LR).DataSeries xlColumns, , , 2
End With
Range("A1").CurrentRegion.Sort Key1:=Range("C1"), _
Order1:=xlAscending, Header:=xlNo, Orientation:=xlSortColumns
Range("C:C").ClearContents
Range("C1").Resize(LR * 2).Value = Ary
Erase Ary
Application.ScreenUpdating = True
End Sub
|
|