简体   繁体   中英

Excel 2016 fails on VBA PasteSpecial

This VBA code is running on Excel 2013 (on multiple different machines):

Sub CopyStaticData()
    Application.ScreenUpdating = False
    Sheets("Data Input").Range("Input_Station_ID").Copy
    Sheets("Data Received").Range("Data_Station_ID").PasteSpecial Paste:=xlPasteValues
    ...

However, on Excel 2016 it throws a runtime error on the last line:

Error 1004: Method 'PasteSpecial' of object 'Range' failed

I tried replacing xlPasteValues with its explicit code (-4163) - to no avail.

Any ideas? A possible Microsoft compatibility issue?

for pasting values only, i recommend not using a copy.

instead, simplify to RangeB.value = RangeA.value .

easier, faster, no tricky clipboard, written in one small line.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM