I'm getting the error below when running this code and it is failing on the last line (paste formats). I use the same basic code on a number of reports but it is only failing on one file. I tried recording the steps manually again via the macro recorder and it also crashed when I tried to do the paste formats. It may have something to do with our move to Office 365 but as I mentioned the same code still works on other files. What I need to do is open the report, retrieve data for the period in question, then run the macro to save a standalone version of the report that can be emailed. The range being copied has collapsed columns/rows and this machine still has Windows 7 if that makes a difference . I'm sure there is also a more efficient way to do the copy/paste sequence so feel free to make suggestions on that.
Run-time error '-2147417848 (80010108)':
Method 'PasteSpecial' of object 'Range' failed
Run-time error '-2147417848 (80010108)':
Method 'PasteSpecial' of object 'Range' failed
VBA Code:
Application.ScreenUpdating = False
wbkSrcName = ActiveWorkbook.Name
rowEnd = Worksheets("Report").Cells(Rows.Count, "C").End(xlUp).Row
Set rngCopy = Sheets("Report").Range("B4:X" & rowEnd)
rngCopy.SpecialCells(xlCellTypeVisible).Copy
Workbooks.Add
wbkOutName = ActiveWorkbook.Name
Range("A1").PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("A1").PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Range("A1").PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False