VBA Create row and transpose

Dancarro

Board Regular
Joined
Feb 23, 2013
Messages
65
Hi,

I have a macro which creates rows according to a column value cell and transposes the rest of columns; and this works fine.

Sub Copydata1()
Dim data1 As Variant, data2 As Variant
Dim i As Long





With Range("A4", Cells(Rows.Count, "A").End(xlUp))
data1 = .Resize(, 21).Value
data2 = .Offset(, 21).Resize(, 33).Value
.Resize(, 33).ClearContents
End With
For i = LBound(data1) To UBound(data1)
With Cells(Rows.Count, 1).End(xlUp).Offset(1)
.Resize(data1(i, 21), 21) = Application.Index(data1, i, 0)
.Offset(, 21).Resize(data1(i, 21), 1) = Application.Transpose(Application.Index(data2, i, 0))
End With
Next


End Sub

The problem is that I have several other columns which I would like to transpose (column position 35 -46) and clear its contents, just as the above but I am having some problems to do this.


Kind Regards
Dan
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Forum statistics

Threads
1,223,243
Messages
6,170,967
Members
452,371
Latest member
Frana

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