With ThisWorkbook.Sheets("WorksheetName").Cells.Range("A1:A1000000")
.Formula = formulavariable
.Value = .Value
End With
当Excel执行.Value = .Value时,它会添加一个'到所有价值观的开头。如果我右键单击并粘贴为值,则会删除'。问题是这个代码是非常有效的,当我尝试删除'加载所有细胞需要永远。
答案 0 :(得分:1)
尝试一下:
Sub testit()
formulavariable = "=1+2"
With ThisWorkbook.Sheets("WorksheetName").Cells.Range("A1:A1000000")
.Clear
.Formula = formulavariable
.Value = .Value
End With
End Sub
修改强>
如果您希望用 Null 填充单元格,那么:
Sub FillWithNulls()
formulavariable = Chr(61) & Chr(34) & Chr(34)
With ThisWorkbook.Sheets("WorksheetName").Cells.Range("A1:A1000000")
.Clear
.Formula = formulavariable
.Value = .Value
End With
End Sub