复制范围,然后将值粘贴到 sheet 的不同部分,然后返回到原始范围

Copy range then paste values to a different section of the sheet then back to the original range

通过单击按钮,我尝试获取一系列数据、粘贴值、删除原始数据范围,然后将值移回原始位置。像这样...

ws.Range("A11:AD400").Copy
ws.Range("A511:AD900").PasteSpecial xlPasteValues
ws.Range("A11:AD400").Select
Selection.SpecialCells(xlCellTypeConstants, 23).Select
Selection.ClearContents
ws.Range("A511:AD900").Copy
ws.Range("A11:AD400").PasteSpecial xlPasteValues
ws.Range("A511:AD900").Select
Selection.SpecialCells(xlCellTypeConstants, 23).Select
Selection.ClearContents

如果您实际上只想恢复正确的格式,请录制一个宏作为目标范围的格式 (ws.Range("A11:AD400"))。然后该代码可以 re-used 作为您的维修代码,您可以 运行 re-format 您将来需要的范围(例如,您可以 link 到一个按钮)。 =14=]

当格式很重要时,比复制、粘贴和复制回效率高得多。

学习使用 macro-recorder:

  1. http://www.excel-easy.com/vba/examples/macro-recorder.html
  2. http://www.contextures.com/excel-macro-record-test.html

范围格式介绍:

  1. http://www.excelhowto.com/macros/formatting-a-range-of-cells-in-excel-vba/