ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Paste Special throwing an error (https://www.excelbanter.com/excel-discussion-misc-queries/202685-paste-special-throwing-error.html)

jlclyde

Paste Special throwing an error
 
I ahve been using this code for almost a year wothout any trouble.
Recently it started to throw an error when it gets to the paste
special line. The error says "PasteSpecial method of class range
failed". Here is my code.

Thanks,
Jay

Sub Cutting()
Dim NextRow As Long
Dim Datei As Date
Datei = Range("E1")

Range("A7:AB26, BL7:BM26").Copy
Application.ScreenUpdating = False
Workbooks.Open filename:="G:\DPE-IPE\DPE REVISIONS\All Press Ips.xls"
Sheets("Cutting").Activate
NextRow = Range("B65536").End(xlUp).Row + 1

Range("B" & NextRow).PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, SkipBlanks:=False, Transpose:=False

Dim theRange As Range
Dim lastRow&, firstRow&, x&
Set theRange = ActiveSheet.UsedRange
lastRow = theRange.Cells(theRange.Cells.Count).Row
firstRow = NextRow
For x = lastRow To firstRow Step -1
If Cells(x, 7) = "" And Cells(x, 12) = "" And Cells(x, 16) = "" _
And Cells(x, 20) = "" And Cells(x, 24) = "" And Cells(x, 28) =
"" Then
Rows(x).Delete
End If
Next
Sheets("Cutting").Range("A" & NextRow).Resize(Range(Range("B" &
NextRow), Range("B65536").End(xlUp)).Count, 1) = Datei

Workbooks("All Press Ips.XLS").Close SaveChanges:=True

End Sub


All times are GMT +1. The time now is 12:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com