Advertisement
Guest User

Untitled

a guest
May 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.66 KB | None | 0 0
  1. Sub test()
  2.  
  3. Dim WB As Workbook
  4. Dim WS As Worksheet
  5. Dim L_Row As Integer
  6. Dim Country As String
  7.  
  8.  
  9. Set WB = ActiveWorkbook
  10. Set WS = WB.Sheets("Arkusz1")
  11. L_Row = WS.Range("A1").CurrentRegion.Rows.Count
  12.  
  13.  
  14. For x = 2 To L_Row
  15.      Country = WS.Range("A" & x)
  16.          For y = x + 1 To L_Row
  17.              If WS.Range("A" & y) = Country And WS.Range("A" & y) <> "" Then
  18.                 WS.Range("B" & x).Value = WS.Range("B" & x).Value + WS.Range("B" & y).Value
  19.                 Rows(y).EntireRow.Clear
  20.              End If
  21.         Next y
  22. Next x
  23.    
  24. Range("A2:E" & L_Row).Sort key1:=Range("A2:A" & L_Row), order1:=xlAscending, Header:=xlNo
  25.    
  26.    
  27. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement