Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub ArchiveTrades()
- Dim MesAtual As Worksheet
- Set MesAtual = Worksheets("MesAtual")
- For Each rw In MesAtual.Rows
- With MesAtual
- If .Cells(rw.Row, 1).Value = "" Then
- Exit For
- End If
- If Format(.Cells(rw.Row, 1).Value, "myyyy") <> Format(Now(), "myyyy") Then
- SendToHistory (rw.Row)
- End If
- End With
- Next rw
- End Sub
- Function SendToHistory(MesAtualRow)
- Dim source As Range
- Dim target As Range
- Dim MesAtual As Worksheet
- Dim Historico As Worksheet
- Dim firstFreeRow As Integer
- Set MesAtual = Worksheets("MesAtual")
- Set Historico = Worksheets("Historico")
- firstFreeRow = Historico.Cells(Rows.Count, 1).End(xlUp).Row + 1
- Set source = MesAtual.Range(MesAtual.Cells(MesAtualRow, 1), MesAtual.Cells(MesAtualRow, 7))
- Set target = Historico.Range(Historico.Cells(firstFreeRow, 1), Historico.Cells(firstFreeRow, 7))
- source.Cut Destination:=target
- End Function
Add Comment
Please, Sign In to add comment