Advertisement
YasserKhalil2019

T3938_Matrix Transpose Rows Format Skills

Sep 19th, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. https://excel-egy.com/forum/t3938
  2. ---------------------------------
  3.  
  4. Sub Matrix_Transpose_Rows_Format_Skills()
  5. Dim a, b, ws As Worksheet, c As Range, r As Range, i As Long, j As Long, k As Long, x As Long
  6.  
  7. Set ws = ThisWorkbook.Worksheets("Report")
  8. a = ws.Range("A1").CurrentRegion.Value
  9. ReDim b(1 To UBound(a, 1) * 11, 1 To 6)
  10. j = 1
  11.  
  12. For i = 2 To UBound(a, 1)
  13. For k = 5 To UBound(a, 2)
  14. For x = 1 To 4
  15. b(j, x) = a(i, x)
  16. Next x
  17.  
  18. b(j, 5) = a(1, k)
  19. b(j, 6) = a(i, k)
  20. j = j + 1
  21. Next k
  22. Next i
  23.  
  24. Application.ScreenUpdating = False
  25. With ws.Range("S1")
  26. .CurrentRegion.Clear
  27. .Resize(, UBound(b, 2)).Value = Array("الحساب", "المندوب", "السنة", "النوع", "الشهر", "القيمة")
  28. .Offset(1).Resize(UBound(b, 1), UBound(b, 2)).Value = b
  29.  
  30. With .CurrentRegion
  31. .HorizontalAlignment = xlCenter
  32. .VerticalAlignment = xlCenter
  33. .Font.Size = 13
  34. .Font.Name = "Arial"
  35. .Rows(1).Font.Bold = True
  36. .Rows(1).Interior.Color = vbCyan
  37. .Columns.AutoFit
  38. End With
  39. End With
  40.  
  41. For Each c In ws.Range("S2:S" & ws.Cells(Rows.Count, "S").End(xlUp).Row)
  42. If c.Value = "النسبة" Then
  43. If r Is Nothing Then Set r = c.Offset(, 5) Else Set r = Union(r, c.Offset(, 5))
  44. End If
  45. Next c
  46. If Not r Is Nothing Then r.NumberFormat = "0%"
  47. Application.ScreenUpdating = True
  48. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement