我在以下表达式上收到错误:
wksWrite.Cells(lWriteRow, "F") = Trim(wksRead.Cells(lReadRow, 2))
因为Trim(wksRead.Cells(lReadRow, 2))
评估为:
=SKYDDSFOLIE FÖR SR-72 5424
我猜Excel会将其评估为公式,并且不允许VBA输入它。但我想将该值作为文本输入。我尝试添加:
wksWrite.Cells(lWriteRow, "B").NumberFormat = "@"
wksWrite.Cells(lWriteRow, "F").Value = CStr(Trim(wksRead.Cells(lReadRow, 2)))
但我仍然得到同样的错误。如何强制Excel将值解释为文本并接受它?
答案 0 :(得分:2)
您可以在将值视为字符串
之前添加单引号wksWrite.Cells(lWriteRow, "F") = "'" & Trim(wksRead.Cells(lReadRow, 2))