View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Martin[_21_] Martin[_21_] is offline
external usenet poster
 
Posts: 50
Default Transpose and VBA Resize command

Dear All,

Thanks to Bernie I have solved a big problem. (Bernie, I started a new
thread in case you wouldn't pick it up in the old one.)

The code below provided by Bernie is working really well. There is one
slight problem - the speed of the execution when there is a large amount of
data. If I turn the calculation off before and back on after it does not
improve the speed. It seems to be down to the Resize command. Is there a way
to make it faster? Any help much appreciated.

Sub MartinDataRearrange()
Dim myA As Range
Dim myR As Range
Dim mySel As String
Dim myRow As Long
Dim i As Long

mySel = Selection.Address

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

myRow = Cells(Rows.Count, 1).End(xlUp).Row

For i = myRow To 2 Step -1
Cells(i, 1).EntireRow.Copy
Cells(i, 1).Resize(9).Insert
Cells(i, 1).Offset(1, 11).Resize(9, 244).ClearContents
Next i

Set myR = Range("L2:U2").Resize((myRow - 2) * 10 + 1). _
SpecialCells(xlCellTypeConstants)

For Each myA In myR.Areas
myA.Cells.Copy
Cells(myA.Cells(1, 1).Row, 2).Resize(10).PasteSpecial Transpose:=True
Next myA

Set myR = Range("V2:AE2").Resize((myRow - 2) * 10 + 1). _
SpecialCells(xlCellTypeConstants)

For Each myA In myR.Areas
myA.Cells.Copy
Cells(myA.Cells(1, 1).Row, 4).Resize(10).PasteSpecial Transpose:=True
Next myA

Range("L:AE").EntireColumn.Delete

Range(mySel).Select

With Application
.ScreenUpdating = True
.EnableEvents = True
End With

End Sub

--
Regards,

Martin