简体   繁体   中英

Excel VBA That command cannot be used on multiple selections

I have got this code:

Worksheets("SOURCE_DATA_HIDDEN").Activate
    Sheets("SOURCE_DATA_HIDDEN").Select
    Columns("B").Copy
    Sheets("RESOURCE_DEMAND").Select
    Columns("C").Select
    ActiveSheet.Paste

I use it to copy and paste a column from one sheet to another. The code used to work last time i checked and it somehow broke today. It comes up with the following error: Run time error 1004: That command cannot be used on multiple selections.

I really cant figure out what is going on. I haven't made any amendments to the code.

尝试清除剪贴板Application.CutCopyMode = False

You can simplify that a lot more. If its just the values you are wanting too, change to PasteSpecial . Try this:

ThisWorkbook.Sheets("SOURCE_DATA_HIDDEN").Columns("B").Copy
ThisWorkbook.Sheets("RESOURCE_DEMAND").Range("C1").PasteSpecial Paste:=xlValues
Application.CutCopyMode = False

Eliminates all the selecting and activating, which is generally a habit you dont want to keep!

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