如何优化这个简单而可怕的实现?可怕、简单

2023-09-06 05:53:34 作者:古道儒风

我基本上要为从细胞中移除公式,但要保留的计算值。

所以,我实现了它很容易和它的伟大工程,但很慢。(约2分钟,1800个细胞)

SO, I implemented it easily and it works great but REALLY SLOW. (About 2 mins for 1800 cells)

我有:

Dim col As Excel.Range = getRange()
For Each cell In col
    cell.Value = cell.Value
Next

我试图这样做是为了在第一单元格,然后自动填充的其余部分,但复制第一单元格的值与细胞的列中的其余部分。

I tried to do this to the first cell and then autofill the rest, but that copied the value of 1st cell to the rest of the cells in column.

那么,我应该怎么做,使之快。

So, what shall I do to make it fast..

我觉得一定有什么相关的自动填充,应该做的伎俩。

请帮助!

推荐答案

如果您知道您的范围的确切地址,或者你可以把它(也许用getRange()?),这似乎为我工作到从细胞中除去一个公式,同时保持结果

If you happen to know the exact address of your range, or you can get it (maybe using getRange()?), this seemed to work for me to remove a formula from the cells while maintaining the result:

Worksheets("Sheet1").Range("A1:F15").Value = Worksheets("Sheet1").Range("A1:F15").Value