excel - Move rows to another sheet after 6 months -


i've been fiddling sheet longer should. list of cars parked in areas shouldn't be. after period of 6 months, trying them automatically "archive" in sheet of workbook. i've been trying find macro after 6 months date in column, automatically cut row , insert next sheet. appreciated. have toiled on 3 days far , brain fried! apparently can't post screenshot because need reputation of 10 (whatever means) can totally email though.

sub worksheet_change(byval target excel.range)      if target.column = 5         application.enableevents = false         if target.value = today() - 180             target.entirerow.copy             worksheets("archive").range("a65536").end(xlup).offset(1, 0).pastespecial paste:=xlpastevaluesandnumberformats             target.entirerow.delete             application.enableevents = true              exit sub         end if     end if        if target.column <> 5 exit sub     if target.row = 2 exit sub     if left(target.offset(0, -1), 1) = "~" exit sub     if left(target.offset(0, -1), 1) = "~" exit sub     if left(target.offset(0, -1), 1) = "=row()-1" exit sub     target.offset(0, -1).formula = "=row()-1"  end sub 

cause information not enough, therefore suppose records has been sorted time , time located on column a

sub moverow() dim drow, hrow double dim s1, s2 integer  drow = 2 hrow = 2 '' number of sheet contain record s1 = 1 '' num ber of sheet history s2 = 2  while sheets(s1).cells(drow, 1) <> empty     ' check if month difference greater or equal 6     if datediff("m", sheets(s1).cells(drow, 1), date) >= 6         sheets(s1).cells(drow, 1).entirerow.cut destination:=sheets(s2).cells(hrow, 1)         sheets(s1).cells(drow, 1).entirerow.delete         hrow = hrow + 1     else         ' if record near 6 months, code end // reduce time process         exit     end if  loop  msgbox ("done") 

end sub


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -