如何使用vb.net替换单元格中的值?

时间:2011-07-26 13:01:29

标签: .net vb.net excel-vba excel-formula vba

我有一个复杂的公式计算单元格的值,它为我计算值。

我想从单元格中删除公式并希望保留计算值。

我有:

Dim range As Excel.Range = getRange()
For Each cell in range
    ' What should do to retain the value and get rid of the formula in the cell.
Next cell

2 个答案:

答案 0 :(得分:3)

怎么样:

For Each cell in range
   cell.Value = cell.Value
Next cell

答案 1 :(得分:0)

如果VBA没有付清,请尝试

  • F2 (编辑) F9 (计算)输入(保存值)单个单元格
  • 将范围和PasteSpecial / Values复制到自身以获得更大的范围