I got this error on Excel 2010, however the code below works perfectly fine on 2007. I changed all the settings on 2010 on Trust Center, but still no go. I am getting the error on the code below (Range("Week" & WeekNo).Copy. Can someone please tell me why this code works in 2007 but does not in 2010? Thanks.
Sub Macro2()
' Keyboard Shortcut: Ctrl+z
'
Dim wbkOtherWorkbook As Workbook
' Set wbkOtherWorkbook = Workbooks("District Foodcost.xls") 'Assuming this workbook is already open
Dim wbMyBook As Workbook
Set wbMyBook = ActiveWorkbook
Set objOutlook = GetObject(, "Outlook.Application")
Dim MySelection As Range
Set MySelection = Application.InputBox(prompt:="Select a Cell ie... G3", Type:=8)
MySelection.Select
' ActiveWorkbook.Sheets("Weekly Food Cost").Activate
Workbooks(1).Activate
Dim WeekNo As Variant
Do
WeekNo = Application.InputBox _
("Enter week number", , , , , , , 1)
If WeekNo = "False" Then
Exit Do
End If
Loop Until WeekNo >= 1 And WeekNo <= 4
Workbooks(2).Activate
If WeekNo <> "False" Then
Range("Week" & WeekNo).Copy
Workbooks(1).Activate
' Windows("District Foodcost.XLS").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
Dim Wb As Workbook
For Each Wb In Workbooks
If Wb.Name <> ThisWorkbook.Name Then
Wb.Close savechanges:=False
End If
Next Wb
Range("E3").Select
' objOutlook.Application.Quit
End Sub
Bookmarks