Advertisement
YasserKhalil2019

T4324_Join Columns Using Evaluate Sort Ascending

Nov 17th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. https://excel-egy.com/forum/t4324
  2. ---------------------------------
  3.  
  4. Sub Join_Columns_Using_Evaluate_Sort_Ascending()
  5. Dim e, x, r As Range, delim As String, s As String
  6.  
  7. Application.ScreenUpdating = False
  8. delim = "|"
  9. For Each e In Array("B1", "I1")
  10. With Range(e).CurrentRegion.Offset(1)
  11. Set r = .Columns(.Columns.Count).Resize(.Rows.Count - 1)
  12. s = s & IIf(s <> "", delim, "") & Join(Filter(r.Parent.Evaluate("TRANSPOSE(IF(" & r.Address & "<>""""," & r.Address & "))"), False, 0), delim)
  13. End With
  14. Next e
  15. x = Split(s, delim)
  16.  
  17. With Range("M2")
  18. .Resize(UBound(x) + 1).Value = Application.Transpose(x)
  19. .CurrentRegion.Sort Range("M2"), xlAscending, , , , , , xlNo
  20. End With
  21. Application.ScreenUpdating = False
  22. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement