ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Transpose macro (https://www.excelbanter.com/excel-programming/425055-transpose-macro.html)

Fred

Transpose macro
 
Hi there! Could maybe someone help me to translate the following problem into
VBA ?

I need a code that helps me to tranpose data that I have in columns into
rows at each change of row:

Header1 Header2 July Aug Sep etc...

Name1 Object1 Data Data Data Data
Name2 Object2
Name3 Object3
etc... etc....

Need to get the following:

Header1 Header2

Name1 Object1 July Data
Name1 Object1 Aug Data
Name1 Object1 Sep Data
Name2 Object2 July Data

I hope this was clear :-)
I truly appreciate all the help.

Kind regards,
Fred

joel

Transpose macro
 
Sub makenewrows()

LastRow = Range("A" & Rows.Count).End(xlUp).Row

For RowCount = LastRow To 3 Step -1
LastCol = Cells(RowCount, Columns.Count).End(xlToLeft).Column
If LastCol 3 Then
For ColCount = LastCol To 4 Step -1
'insert new row
Rows(RowCount + 1).Insert
Range("A" & (RowCount + 1)) = _
Range("A" & RowCount)
Range("B" & (RowCount + 1)) = _
Range("B" & RowCount)
Range("C" & (RowCount + 1)) = _
Cells(1, ColCount)

Range("D" & (RowCount + 1)) = _
Cells(RowCount, ColCount)

Cells(RowCount, ColCount) = ""

Next ColCount
End If
'move column 3
Range("D" & RowCount) = _
Range("C" & RowCount)
Range("C" & RowCount) = Range("C1")
Next RowCount

End Sub


"Fred" wrote:

Hi there! Could maybe someone help me to translate the following problem into
VBA ?

I need a code that helps me to tranpose data that I have in columns into
rows at each change of row:

Header1 Header2 July Aug Sep etc...

Name1 Object1 Data Data Data Data
Name2 Object2
Name3 Object3
etc... etc....

Need to get the following:

Header1 Header2

Name1 Object1 July Data
Name1 Object1 Aug Data
Name1 Object1 Sep Data
Name2 Object2 July Data

I hope this was clear :-)
I truly appreciate all the help.

Kind regards,
Fred



All times are GMT +1. The time now is 11:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com