How to copy only plain text of cells in Excel?

前端 未结 7 453
情书的邮戳
情书的邮戳 2021-01-03 04:29

I am designing an Excel worksheet where the user will click a command button which copies a predetermined range of cells. The user would then paste the contents into a web a

7条回答
  •  清酒与你
    2021-01-03 05:01

    If you're dealing with a lot of cells to be copied, the selection.copy method will be extremely slow. (I experienced that when running a macro on 200 000 records).

    A 100 times more performant way is to directly assign the value of one cell to another. Example from my code:

    With errlogSheet
             'Copy all data from the current row
    
              reworkedErrorSheet.Range("A" & reworkedRow).Value = .Range("A" & currentRow).Value
              reworkedErrorSheet.Range("B" & reworkedRow).Value = .Range("B" & currentRow).Value
              reworkedErrorSheet.Range("C" & reworkedRow).Value = .Range("C" & currentRow).Value
              reworkedErrorSheet.Range("D" & reworkedRow).Value = .Range("D" & currentRow).Value
              reworkedErrorSheet.Range("E" & reworkedRow).Value = .Range("E" & currentRow).Value
    

提交回复
热议问题