I have a question on how to convert columns to rows, i tried and my macros was able to get most except for the header row. I would appreciate if anyone can help me where i'm having issues in my code. Also how do i upload my excel if i want to share what i'm trying to explain.
My data is like this
[pre]
[/pre]
My Macro[/b]
Sub test()
lastrow = Range("A" & Rows.Count).End(xlUp).Row
destrow = lastrow + 1
For i = 2 To lastrow
For Each Cell In Range("F" & i & ":Q" & i)
If Cell <> "" Then
Cells(destrow, 1).Value = Cells(i, 1).Value
Cells(destrow, 2).Value = Cells(i, 2).Value
Cells(destrow, 3).Value = Cells(i, 3).Value
Cells(destrow, 4).Value = Cells(i, 4).Value
If Cells(i, 5).Value = "" Then
Cells(destrow, 5).Value = ""
Else
Cells(destrow, 5).Value = Cells(i, 5).Value
End If
'need the header 200401 .. here
'Cells(destrow,6) = "Header"
Cells(destrow, 7) = Cell.Value
destrow = destrow + 1
End If
Next Cell
Next i
End Sub[/code][/pre]
Thanks in Advance
My data is like this
[pre]
Code:
Brand Store Name open Date close Date 200401 200402 200403 200404
SS1 1 ABC 01/01/2002 C C Relo Relo
SS1 2 DEF 12/01/2002 C C C C
SS1 3 DEF 07/08/2004 C C
I want my output to be
[b]Output
[pre][code]Brand Store Name Open Date Close Date MonthYr Status
SS1 1 ABC 01/01/2002 200401 C
SS1 1 ABC 01/01/2002 200402 C
SS1 1 ABC 01/01/2002 200403 Relo
SS1 1 ABC 01/01/2002 200404 Relo
SS1 2 DEF 12/01/2002 200401 C
SS1 2 DEF 12/01/2002 200402 C
SS1 2 DEF 12/01/2002 200403 C
SS1 2 DEF 12/01/2002 200404 C
SS1 3 DEF 07/08/2004 200403 C
SS1 3 DEF 07/08/2004 200404 C
My Macro[/b]
Sub test()
lastrow = Range("A" & Rows.Count).End(xlUp).Row
destrow = lastrow + 1
For i = 2 To lastrow
For Each Cell In Range("F" & i & ":Q" & i)
If Cell <> "" Then
Cells(destrow, 1).Value = Cells(i, 1).Value
Cells(destrow, 2).Value = Cells(i, 2).Value
Cells(destrow, 3).Value = Cells(i, 3).Value
Cells(destrow, 4).Value = Cells(i, 4).Value
If Cells(i, 5).Value = "" Then
Cells(destrow, 5).Value = ""
Else
Cells(destrow, 5).Value = Cells(i, 5).Value
End If
'need the header 200401 .. here
'Cells(destrow,6) = "Header"
Cells(destrow, 7) = Cell.Value
destrow = destrow + 1
End If
Next Cell
Next i
End Sub[/code][/pre]
Thanks in Advance