Hi Guys
I'm having some troubles with my macros.
Basically it goes through and checks how old certain records are and if they are over a certain age it moves it to a archive file (to keep the working file small and running fast)
This is the code that checks the records to see how old they are. it works fine. not a problem
this is the code that will copy and paste the data to the archieve.
First section checks that both workbooks are readwrite
Then the second section will move the range RAR. That works.
Then the third section is the code that I have problems with it.
It is the same as the 2nd section but it always cause an error with this section of code.
any ideas as to why it doesnt want to copy?
I'm having some troubles with my macros.
Basically it goes through and checks how old certain records are and if they are over a certain age it moves it to a archive file (to keep the working file small and running fast)
Code:
Sub INVCheck()
'Spec Archieve Checks
For Each CL In Workbooks(INV).Sheets("Specs Archive").Range("A4:A" & Workbooks(INV).Sheets("Specs Archive").Range("a65536").End(xlUp).Row)
If DateDiff("m", CL.Offset(0, 10), Date) > 3 Then
If Not SAR = vbNullString Then
SAR = SAR & ","
End If
SAR = SAR & CL.Row & ":" & CL.Row
End If
Next CL
'Register Checks
For Each CL In Workbooks(INV).Sheets("Register").Range("A4:A" & Workbooks(INV).Sheets("Register").Range("a65536").End(xlUp).Row)
If DateDiff("d", CL.Offset(0, 10), Date) > 12 Then
If CL.Offset(0, 35) = vbNullString Then
If Not RAR = vbNullString Then
RAR = RAR & ","
End If
RAR = RAR & CL.Row & ":" & CL.Row
Else
If DateDiff("d", CL.Offset(0, 37), Date) > 12 And CL.Offset(0, 39) = vbNullString Then
If Not RAR = vbNullString Then
RAR = RAR & ","
End If
RAR = RAR & CL.Row & ":" & CL.Row
Else
If Not CL.Offset(0, 39) = vbNullString And DateDiff("d", CL.Offset(0, 41), Date) > 12 Then
If Not RAR = vbNullString Then
RAR = RAR & ","
End If
RAR = RAR & CL.Row & ":" & CL.Row
End If
End If
End If
End If
Next CL
End Sub
This is the code that checks the records to see how old they are. it works fine. not a problem
Code:
Sub Cleanup()
Application.ScreenUpdating = False
Application.Calculation = xlManual
If Workbooks(INV).ReadOnly = True Then
MsgBox "Cannot run the Clean up when " & INV & " is Read Only"
Exit Sub
End If
Workbooks.Open (MyPath & AF)
If Workbooks(AF).ReadOnly = True Then
MsgBox "Cannot run the Clean up when " & AF & " is Read Only"
Windows(AF).Close
Exit Sub
End If
Call INVCheck
If Not RAR = vbNullString Then
Workbooks(INV).Activate
Sheets("Register").Select
Range(RAR).Select
Selection.Copy
Workbooks(AF).Activate
Sheets("Releases").Select
Range("a65536").End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
Workbooks(INV).Activate
Range(RAR).Select
Selection.Delete
Range("A1").Select
Else
MsgBox "No RAR"
End If
Call INVCheck
If Not SAR = vbNullString Then
Workbooks(INV).Activate
Sheets("Specs Archive").Select
Range(SAR).Select
Selection.Copy
Workbooks(AF).Activate
Sheets("Specss").Select
Range("a65536").End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
Workbooks(INV).Activate
Range(SAR).Select
Selection.Delete
Range("A1").Select
Else
MsgBox "No SAR"
End If
Windows(AF).Close True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
this is the code that will copy and paste the data to the archieve.
First section checks that both workbooks are readwrite
Then the second section will move the range RAR. That works.
Then the third section is the code that I have problems with it.
It is the same as the 2nd section but it always cause an error with this section of code.
Code:
Selection.Copy
any ideas as to why it doesnt want to copy?