paulageville
New Member
- Joined
- Oct 4, 2011
- Messages
- 9
Hi people,
I'm pretty new to vba and keep getting a run time error 1004 on the highlighted line when i run the following macro...
<code>
Sub auto_open()
Dim cwb As Workbook
Dim arow As Long
Dim brow As Long
Application.ScreenUpdating = False
Set cwb = ThisWorkbook
Sheets("Domestic Matrix").Activate
For Each Cell In ActiveSheet.UsedRange.Cells
If Cell.Value < Date - 365 Then
arow = cwb.Worksheets("Training Overdue").Range("A").End(xlUp).Row <<<<<<<<<<<
arow = arow + 1
cwb.Worksheets("Domestic Matrix").Range(ActiveCell.End(xlUp).Offset(1)).Copy
cwb.Worksheets("Training Overdue").Range("A" & arow + 3).PasteSpecial xlPasteValues
brow = cwb.Worksheets("Training Overdue").Range("B").End(xlUp).Row
brow = brow + 1
cwb.Worksheets("Domestic Matrix").Range(ActiveCell.End(xlLeft).Offset(0, 1)).Copy
cwb.Worksheets("Training Overdue").Range("B" & arow + 3).PasteSpecial xlPasteValues
Else
End If
Next
End Sub
</code>
basically I have a load of dates in a load of different cells.
What i want the macro to do is find each cell containing a date that is more than a year since current date.
For each such cell found, i want to paste the values from the 2nd cell in that row and the 2nd cell in that column into another worksheet (training overdue).
I hope that makes sense!
Not sure where I'm going wrong....
Please help!!
I'm pretty new to vba and keep getting a run time error 1004 on the highlighted line when i run the following macro...
<code>
Sub auto_open()
Dim cwb As Workbook
Dim arow As Long
Dim brow As Long
Application.ScreenUpdating = False
Set cwb = ThisWorkbook
Sheets("Domestic Matrix").Activate
For Each Cell In ActiveSheet.UsedRange.Cells
If Cell.Value < Date - 365 Then
arow = cwb.Worksheets("Training Overdue").Range("A").End(xlUp).Row <<<<<<<<<<<
arow = arow + 1
cwb.Worksheets("Domestic Matrix").Range(ActiveCell.End(xlUp).Offset(1)).Copy
cwb.Worksheets("Training Overdue").Range("A" & arow + 3).PasteSpecial xlPasteValues
brow = cwb.Worksheets("Training Overdue").Range("B").End(xlUp).Row
brow = brow + 1
cwb.Worksheets("Domestic Matrix").Range(ActiveCell.End(xlLeft).Offset(0, 1)).Copy
cwb.Worksheets("Training Overdue").Range("B" & arow + 3).PasteSpecial xlPasteValues
Else
End If
Next
End Sub
</code>
basically I have a load of dates in a load of different cells.
What i want the macro to do is find each cell containing a date that is more than a year since current date.
For each such cell found, i want to paste the values from the 2nd cell in that row and the 2nd cell in that column into another worksheet (training overdue).
I hope that makes sense!
Not sure where I'm going wrong....
Please help!!