Guest User

Untitled

a guest
Jul 17th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. Sub ArchiveTrades()
  2. Dim MesAtual As Worksheet
  3. Set MesAtual = Worksheets("MesAtual")
  4. For Each rw In MesAtual.Rows
  5. With MesAtual
  6. If .Cells(rw.Row, 1).Value = "" Then
  7. Exit For
  8. End If
  9. If Format(.Cells(rw.Row, 1).Value, "myyyy") <> Format(Now(), "myyyy") Then
  10. SendToHistory (rw.Row)
  11. End If
  12. End With
  13. Next rw
  14. End Sub
  15.  
  16. Function SendToHistory(MesAtualRow)
  17. Dim source As Range
  18. Dim target As Range
  19. Dim MesAtual As Worksheet
  20. Dim Historico As Worksheet
  21. Dim firstFreeRow As Integer
  22. Set MesAtual = Worksheets("MesAtual")
  23. Set Historico = Worksheets("Historico")
  24. firstFreeRow = Historico.Cells(Rows.Count, 1).End(xlUp).Row + 1
  25.  
  26. Set source = MesAtual.Range(MesAtual.Cells(MesAtualRow, 1), MesAtual.Cells(MesAtualRow, 7))
  27. Set target = Historico.Range(Historico.Cells(firstFreeRow, 1), Historico.Cells(firstFreeRow, 7))
  28. source.Cut Destination:=target
  29. End Function
Add Comment
Please, Sign In to add comment