Advertisement
YasserKhalil2019

T4072_Tabular Transpose By Arrays Columns First

Oct 9th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. https://excel-egy.com/forum/t4072
  2. ----------------------------------
  3.  
  4. Sub Tabular_Transpose_By_Arrays_Columns_First()
  5. Dim a, b, i As Long, j As Long, k As Long
  6.  
  7. a = Sheets("Sheet1").Range("A3:D" & Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row).Value
  8. ReDim b(1 To UBound(a, 1) * 3, 1 To 2)
  9. k = 1
  10.  
  11. For j = LBound(a, 2) + 1 To UBound(a, 2)
  12. For i = LBound(a, 1) To UBound(a, 1)
  13. If Not IsEmpty(a(i, j)) Then
  14. b(k, 1) = a(i, 1)
  15. b(k, 2) = a(i, j)
  16. k = k + 1
  17. End If
  18. Next i
  19. Next j
  20.  
  21. With Sheets("Sheet1").Range("K1")
  22. .Resize(, UBound(b, 2)).Value = Array("Month", "Value")
  23. .Offset(1).Resize(UBound(b, 1), UBound(b, 2)).Value = b
  24. End With
  25. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement