Dear all,
I have an issue in my Code.
Sometimes it runs without issues, and sometimes not. I have not found the system.
I want to copy a named area in a sheet in current wb (XLSM) to a new workbook. As default, new wb's are xlsx.
I have read somewhere, that this error can occur, if the new wb is xls. But that is not the case.
In the worksheet there are som hidden columns, but these are not part if the named area.
When an issue occurs, it is the same place. Please see the red line below.
Sub MailAnalysisSub()
Application.ScreenUpdating = False
Dim TempWorkbook As Workbook
Dim Tempsht As Worksheet
'----------
'Create new Workbook
Set TempWorkbook = Workbooks.Add
FolderPath = Application.ThisWorkbook.Path & "\14.ShipReport_Controller" & "\14.ShipReport_SentReportingPackages\"
Application.DisplayAlerts = False
TempWorkbook.Activate
Set Tempsht = Worksheets.Add
Tempsht1 = ActiveSheet.Name
ActiveSheet.Name = "Tempsht1"
'------------
ThisWorkbook.Worksheets("Input_Risk").Activate
ThisWorkbook.Worksheets("Input_Risk").Unprotect
Range("PrintArea_NotPaymentRisk").Select
Selection.Copy
TempWorkbook.Activate
Sheets("Tempsht1").Activate
Cells(1, 1).Activate
Selection.PasteSpecial Paste:=xlPasteValues
Selection.PasteSpecial Paste:=xlPasteFormats
Selection.Name = "PrintArea_NotPaymentRisk"
Application.CutCopyMode = False
...more code.......
I hope you can shed som light over this issue - what am I doing wrong, and most exciting, why is this not a consequence error. Sometimes it works, sometimes not.
wbr
Benjamin
Bookmarks