TButhe
12-16-2004, 01:16 PM
I am trying to use xldown to select a range of cells and clear the contents. I have recorded the code and it turns out exactly the same. However, when I try to run it I get an error "Compile error: Expected function or variable" (if it is expected then why is it an error???:D ) and the xldown is highlighted as the error. What could be wrong? I have used this and am using it in another macro and it works fine. Is it just something in this macro that I have wrong?
Sub Copy3()
' Copy3 Macro
' Macro recorded 12/15/2004 by Tracy Buthe
ActiveSheet.Unprotect
Columns("R:R").Select
Selection.ClearContents
Columns("P:P").Select
Selection.Copy
Columns("R:R").Select
ActiveSheet.Paste
Columns("N:N").Select
Selection.Copy
Columns("P:P").Select
ActiveSheet.Paste
Columns("L:L").Select
Selection.Copy
Columns("N:N").Select
ActiveSheet.Paste
Columns("J:J").Select
Selection.Copy
Columns("L:L").Select
ActiveSheet.Paste
Columns("H:H").Select
Selection.Copy
Columns("J:J").Select
ActiveSheet.Paste
Columns("F:F").Select
Selection.Copy
Columns("H:H").Select
ActiveSheet.Paste
Range("F4") = InputBox("Enter the last day of the month you are working with, such as 3/31/04")
Columns("F:F").Select
Selection.NumberFormat = "General"
Range("F4").Select
Selection.NumberFormat = "[$-409]mmm-yy;@"
Columns("F:F").Select
Selection.Locked = False
Selection.FormulaHidden = False
Range("F1:F4").Select
Selection.Locked = True
Selection.FormulaHidden = False
Range("F5").Select
Selection.End(xldown).Select
Selection.ClearContents
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowInsertingRows:=True, AllowDeletingRows:=True, AllowFiltering:=True _
, AllowUsingPivotTables:=True, AllowSorting:=True
End Sub
Thanks!
TJ
:pacsmile:
Sub Copy3()
' Copy3 Macro
' Macro recorded 12/15/2004 by Tracy Buthe
ActiveSheet.Unprotect
Columns("R:R").Select
Selection.ClearContents
Columns("P:P").Select
Selection.Copy
Columns("R:R").Select
ActiveSheet.Paste
Columns("N:N").Select
Selection.Copy
Columns("P:P").Select
ActiveSheet.Paste
Columns("L:L").Select
Selection.Copy
Columns("N:N").Select
ActiveSheet.Paste
Columns("J:J").Select
Selection.Copy
Columns("L:L").Select
ActiveSheet.Paste
Columns("H:H").Select
Selection.Copy
Columns("J:J").Select
ActiveSheet.Paste
Columns("F:F").Select
Selection.Copy
Columns("H:H").Select
ActiveSheet.Paste
Range("F4") = InputBox("Enter the last day of the month you are working with, such as 3/31/04")
Columns("F:F").Select
Selection.NumberFormat = "General"
Range("F4").Select
Selection.NumberFormat = "[$-409]mmm-yy;@"
Columns("F:F").Select
Selection.Locked = False
Selection.FormulaHidden = False
Range("F1:F4").Select
Selection.Locked = True
Selection.FormulaHidden = False
Range("F5").Select
Selection.End(xldown).Select
Selection.ClearContents
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowInsertingRows:=True, AllowDeletingRows:=True, AllowFiltering:=True _
, AllowUsingPivotTables:=True, AllowSorting:=True
End Sub
Thanks!
TJ
:pacsmile: