Copying and pasting data using VBA code

后端 未结 2 1967
遥遥无期
遥遥无期 2020-12-06 05:55

I have a button on a spreadsheet that, when pressed, should allow the user to open a file, then copy columns A-G of the spreadsheet \"Data\", then paste the data from those

2条回答
  •  醉话见心
    2020-12-06 06:18

    Use the PasteSpecial method:

    sht.Columns("A:G").Copy
    Range("A1").PasteSpecial Paste:=xlPasteValues
    

    BUT your big problem is that you're changing your ActiveSheet to "Data" and not changing it back. You don't need to do the Activate and Select, as per my code (this assumes your button is on the sheet you want to copy to).

提交回复
热议问题