KathrynAlty
New Member
- Joined
- Jan 22, 2016
- Messages
- 6
I wonder if anyone might be able to help me?
I've come across an error in a workbook set up for the 2016 year (it was a direct copy of the 2015 original, clearing previous data and updating the date range).
When I run the macro in the 2016 file, I am presented with the following error: "Run-time error '1004': Application-defined or object-defined error" on the bold red line below.
VBA Code:
Sub Filter_Copy()
Application.ScreenUpdating = False
msg1 = MsgBox("Filter and Copy data. Are you sure?", vbYesNo)
If msg1 = vbNo Then Exit Sub
ActiveSheet.Unprotect
Sheets("Front").Select
Range("F:G").AdvancedFilter Action:=xlFilterInPlace, Unique:=True
Range("B4").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Sheets("Case Data").Select
Range("B3").End(xlDown).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Front").Select
ActiveSheet.ShowAllData
Range("B4").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.ClearContents
Range("B4").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Application.ScreenUpdating = True
msg1 = MsgBox("All data filtered and copied", vbOKOnly)
End Sub
I've read through a lot of these forums regarding this exact error but can't seem to find a solution that works! Hoping that someone can point me in the right direction (apologies if this has been answered before!).
Thank you in advance.
I've come across an error in a workbook set up for the 2016 year (it was a direct copy of the 2015 original, clearing previous data and updating the date range).
When I run the macro in the 2016 file, I am presented with the following error: "Run-time error '1004': Application-defined or object-defined error" on the bold red line below.
VBA Code:
Sub Filter_Copy()
Application.ScreenUpdating = False
msg1 = MsgBox("Filter and Copy data. Are you sure?", vbYesNo)
If msg1 = vbNo Then Exit Sub
ActiveSheet.Unprotect
Sheets("Front").Select
Range("F:G").AdvancedFilter Action:=xlFilterInPlace, Unique:=True
Range("B4").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Sheets("Case Data").Select
Range("B3").End(xlDown).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Front").Select
ActiveSheet.ShowAllData
Range("B4").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.ClearContents
Range("B4").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Application.ScreenUpdating = True
msg1 = MsgBox("All data filtered and copied", vbOKOnly)
End Sub
I've read through a lot of these forums regarding this exact error but can't seem to find a solution that works! Hoping that someone can point me in the right direction (apologies if this has been answered before!).
Thank you in advance.