Hi I'm a novice with VBA and the below may not be done in a VBA professional method; this code has worked without issue for the last 1.5 years until a recent update to Office 365 ProPlus Version 15.0.4693.1002 - a role back to an earlier version of Office 365 ProPlus and the code works.
The Code:
Private Sub CommandButton1_Click()
thiswkbook = ActiveWorkbook.Name
Sheets("paste cand. full report here").Visible = True
Dim MyFileName As Variant
MyFileName = Application.GetOpenFilename(, , "Select Programme")
MyFileName = Mid(MyFileName, InStrRev(MyFileName, "\") + 1)
If MyFileName = "False" Then
Sheets("paste cand. full report here").Visible = False
Exit Sub
End If
Workbooks.Open MyFileName
If ActiveSheet.Range("c1") = "mname" Then GoTo EM2:
Cells.Select
Cells.Copy
Windows(thiswkbook).Activate
Sheets("paste cand. full report here").Select
Cells.PasteSpecial
Dim pt As PivotTable
Dim WS As Worksheet
Application.CutCopyMode = False
Workbooks(MyFileName).Close SaveChanges:=False
GoTo Last:
EM2:
Last:
Sheets("paste cand. full report here").Visible = False
End Sub
Error Message:
Run-time error ‘-2147417848 (80010108)’:
Method ‘PasteSpecial’ of object ‘Range’ Failed
I would appreciate any assistance with the above.
Thanks
Steven
Bookmarks