Transpose macro

F

Fred

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
 
J

Joel

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top