helpneeded2
Board Regular
- Joined
- Jun 25, 2021
- Messages
- 110
- Office Version
- 365
- Platform
- Windows
I was using the code below fine for 2 days, and now it is giving me an error. Any suggestions as to why?
The error I am getting is "Run-time error '1004': PasteSpecial method of Range class failed
The error I am getting is "Run-time error '1004': PasteSpecial method of Range class failed
VBA Code:
Sub Obtain_OLG_Patron_Data()
Dim wbkSource As Workbook
Dim endOfRows As Long
Set wbkSource = ThisWorkbook
' Open, find last row of data, and copy data from OLG MASTER CSV File
Workbooks.Open ("G:\Department\Division\Unit\Protected Document\OLG Master Lists\OLG MASTER TO DATE.xlsx")
endOfRows = ActiveSheet.Range("A:A").Find("*", , xlValues, , xlByRows, xlPrevious).Row
Range("A1").Resize(endOfRows, 42).Select
Selection.Copy
' Paste Data into OLG Sheet
wbkSource.Worksheets("OLG_MASTER").Range("A2").PasteSpecial Paste:=xlPasteValues
' Copy cell value to quickly clear clipboard
wbkSource.Worksheets("OLG_MASTER").Range("A2").Copy
' Close OLG MASTER CSV File
Workbooks("OLG MASTER TO DATE.xlsx").Close SaveChanges:=False
' Return focus to OLG Sheet, and cancel copy mode
wbkSource.Worksheets("OLG_MASTER").Range("A2").Select
Application.CutCopyMode = False
End Sub