Cow,
Sorry! I did not see your attachment. I do not know how I missed it and subsequently asked you to attach again. Here is the amended code. It is not good for the eye to see, but it does the job. If I had the time, I would have written a short code.
Sub Macroloop()
Dim a, b, i As Long, j As Long, k As Long, n As Long, m As Long
a = Sheets("Before").Range("a2").CurrentRegion
n = 1
ReDim b(1 To UBound(a, 1) * UBound(a, 2), 1 To UBound(a, 1))
b(1, 1) = "SERVC_CD"
For i = 2 To UBound(a, 2)
For j = 1 To UBound(a, 1)
n = n + 1
b(n, 3) = a(1, i)
Next
Next
m = 1
For i = 2 To UBound(a, 2)
For j = 2 To UBound(a, 1)
m = m + 1
b(m, 2) = a(j, i)
Next
Next
k = 1
For i = 2 To UBound(a, 1)
k = k + 1
b(k, 1) = a(i, 1)
Next
Sheets("After").Cells.ClearContents
Sheets("After").Range("A1").Resize(n, UBound(a, 2)) = b
Sheets("After").Range("A1").Resize(m, UBound(a, 2)) = b
Sheets("After").Range("A1").Resize(k, UBound(a, 2)) = b
End Sub
Bookmarks