Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. Sub G()
  2.  
  3. Dim strFinal$
  4. Dim cell As Range
  5. Dim rngSource As Range
  6. Dim rngArea As Range
  7. Dim rngTarget As Range
  8.  
  9.  
  10. Set Target = Selection.Cells(1, 1)
  11. Set Start = 2
  12.  
  13. for i = 2
  14.  
  15. For Each rngArea In rngSource
  16. For Each cell In rngArea
  17. strFinal = strFinal & cell.Value & " "
  18. cell.Value = ""
  19. cell.Delete
  20. Next
  21. Next
  22. strFinal = Left$(strFinal, Len(strFinal) - 1)
  23. rngTarget.Value = strFinal
  24.  
  25. End Sub
  26.  
  27. Sub Test()
  28.  
  29. Debug.Print (Selection.Rows.Count)
  30.  
  31. End Sub
  32.  
  33.  
  34. Sub DeleteRow_and_Merge()
  35.  
  36. Dim k As Integer
  37.  
  38. For k = Selection.Rows.Count To 2 Step -1
  39. Selection.Cells(k - 1, 1) = Selection.Cells(k - 1, 1).Value & " " & Selection.Cells(k, 1)
  40. Selection.Cells(k, 1).Delete
  41.  
  42. Next k
  43.  
  44. End Sub
  45.  
  46.  
  47. Private Sub Workbook_Open()
  48.  
  49. End Sub
  50.  
  51. Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
  52. Application.OnKey "{F10}", "DeleteRow_and_Merge"
  53. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement