简体   繁体   中英

Inserting value into Excel cell instead of formula

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 = ....

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM