I assumed your data start at A1. try this one.
Sub movetest()
Dim Stcell As Range, Encell As Range, Nxcell As Range
Dim n As Long
Application.ScreenUpdating = False
Set Stcell = Cells(1, "A")
Do While (Stcell <> "")
Set Encell = Cells(Stcell.Row, Cells.Columns.Count).End(xlToLeft)
n = Range(Stcell, Encell).Cells.Count
If n > 2 Then
Set Nxcell = Stcell.Offset(1, 0)
Nxcell.Resize(n - 2).EntireRow.Insert
Stcell.Offset(0, 2).Resize(, n - 2).Copy
Stcell.Offset(1, 0).PasteSpecial Transpose:=True
Stcell.Offset(0, 2).Resize(, n - 2).ClearContents
Set Stcell = Nxcell
Else
Set Stcell = Stcell.Offset(1, 0)
End If
Loop
On Error Resume Next
For Each Stcell In Columns("A").SpecialCells(xlCellTypeBlanks)
Stcell.EntireRow.Delete
Next
End Sub
Keiji
zorakramone wrote:
> Hi
>
> im trying to write a macro that will allow me to automat, inserting
> rows based on the number of columns filled by names, then transpose
> the names into the rows created.
>
> E.g. from this...
>
> Dave Peter Susan Luke Sam
> Bob Brad Pedro
> Joanna Pedro Danielle Jim
>
>
> to this....
>
> Dave Peter
> Susan
> Luke
> Sam
> Bob Brad
> Pedro
> Joanna Pedro
> Danielle
> Jim
>
> any help would be kindly appreciated
|