将值插入 Excel 单元格而不是公式

发布于 2024-08-25 05:30:12 字数 331 浏览 3 评论 0原文

我有一个 VBA 脚本,可以将长字符串插入 Excel 单元格。在某些情况下,字符串以 = 开头。 Excel 似乎将此解释为公式,并且由于公式的内存限制,我收到内存不足错误。

如何告诉 Excel 我正在写入一个值,而不是一个公式?目前,我正在这样做:

ws.Range("A" & row) = Mid(xml, first, CHUNK_SIZE)

我尝试了以下代码,但它不起作用......

ws.Range(...).Value = ....

I have a VBA script that inserts long strings into Excel cells. In some cases, the string begins with a =. It seems like Excel interprets this as a formula and I get an Out of Memory error due to the memory limitations of formulas.

How do I tell Excel that I am writing a value, not a formula? Currently, I am doing this:

ws.Range("A" & row) = Mid(xml, first, CHUNK_SIZE)

I have tried the following code, but it doesn't work...

ws.Range(...).Value = ....

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

滥情哥ㄟ 2024-09-01 05:30:12

= 符号之前附加 '

Sub Test()

     'This returns 30 in cell Al
      Range("A1").Value = "=SUM(10,10,10)"

      'This shows formula as text in cell A2
      Range("A2").Value = "'" & "=SUM(10,10,10)"

End Sub

Append a ' before the = sign:

Sub Test()

     'This returns 30 in cell Al
      Range("A1").Value = "=SUM(10,10,10)"

      'This shows formula as text in cell A2
      Range("A2").Value = "'" & "=SUM(10,10,10)"

End Sub
青春有你 2024-09-01 05:30:12

在字符串的开头添加一个撇号'(excel认为是一个公式),excel应该将其解释为字符串而不是公式。

Add an apostrophe ' to the beginning of the string (that excel thinks is a formula) and excel should interpret it as a string instead of a formula.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文