Advertisement
Guest User

Untitled

a guest
Jul 17th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. Sub repeatingrows()
  2.  
  3. Dim oldsheet As Worksheet
  4. Dim newsheet As Worksheet
  5. Set newsheet = Application.ActiveSheet
  6.  
  7. Set oldsheet = ThisWorkbook.Worksheets(3)
  8. Set newsheet = ThisWorkbook.Worksheets(2)
  9.  
  10.  
  11. 'CHECK IF THE ROWS ARE SIMILAIR TO PREVIOUS SHEET
  12.  
  13. Dim rrow As Integer
  14. Dim srow As Integer
  15.  
  16. For rrow = 3 To 397
  17. For srow = 3 To 397
  18. If oldsheet.Cells(rrow, 2) = newsheet.Cells(srow, 2) Then
  19. If oldsheet.Cells(rrow, 5) = newsheet.Cells(srow, 5) Then
  20. If oldsheet.Cells(rrow, 6) = newsheet.Cells(srow, 6) Then
  21. With newsheet
  22. oldsheet.Range(oldsheet.Cells(rrow, 16), oldsheet.Cells(rrow, 19)).Copy
  23. .Range(.Cells(srow, 16), .Cells(srow, 19)).PasteSpecial xlPasteValues, xlPasteSpecialOperationAdd
  24. End With '^COPY AND PASTES THE ROW
  25. Else
  26. End If
  27. Else
  28. End If
  29. Else
  30. End If
  31. Next srow
  32. Next rrow
  33.  
  34. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement