我有这段代码,我从表格中获取数据"数据"并将其移动到其他工作表(目的地)。但是,出于某种原因,当代码到达"数据"的删除面时代码停止执行。代码实际上删除了"数据"但是没有任何反应......上个月这个执行完美,而且总是有。它可能是我的Excel 2010设置,权限或我的代码错误(虽然它看起来正确)...
Public Function backupfunction(PathName, UnderPath, FileName)
'Find date
dato = Range("datecell").Value
'open file
Workbooks.Open FileName:=PathName & UnderPath & FileName & ".xlsb"
'Backup of file
ActiveWorkbook.SaveAs FileName:=PathName & "history\" & date & "\" & UnderPath & FileName & " " & dato & ".xlsb"
',FileFormat:=xlExcel12,CreateBackup:=False
'Move data from sheet "data" over to destination sheets
Sheets("D.FF").Range("A3:D1000").ClearContents
Sheets("data").Activate
Range("J2:M2").Select
Range(Selection, Selection.End(xlDown)).Copy
Sheets("D.FF").Range("A3").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Sheets("data").Range("C2:G62").Copy
Sheets("D.s1").Range("C5").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Sheets("data").Range("H2:I62").Copy
Sheets("D.s1").Range("I5").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Sheets("data").Range("N2:R9").Copy
Sheets("D.s12").Range("C5").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Sheets("data").Range("Z2:AA6").Copy
Sheets("D.s12").Range("C16").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
dato = DateSerial(Sheets("res").Range("S2").Value, _
Sheets("res").Range("T2").Value + 1, 1) - 1
Sheets("D.s12").Range("C22").Value = dato
'delete sheet 'data'
Application.DisplayAlerts = False
Sheets("data").Delete
Sheets("Summary").Select
'Store new workbook
ActiveWorkbook.SaveAs FileName:=PathName & UnderPath & FileName & ".xlsb", _
FileFormat:=xlExcel12, _
CreateBackup:=False
Application.DisplayAlerts = True
ActiveWorkbook.Close
BackupEnFil = ok
End Function