将包含与号的公式插入单元格 [英] Inserting a formula containing an ampersand into a cell
本文介绍了将包含与号的公式插入单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在A1单元格中创建一个包含与号的字符的公式,在Excel中看起来像这样:
I'm trying to create a formula in the A1 cell which contains an ampersand character that looks something like this in Excel:
="Hello, "&A2
我的VBA代码如下:
Worksheets("Sheet1").Range("A1").Formula = "=""Hello, "" & "&A2"
VBA抛出错误,我不知道为什么。我尝试使用double和符号,并在各个地方用双引号引起,并且无法解决此错误。
VBA is throwing errors, and I can't figure out why. I've tried using double ampersands, and double quotes in various places and can't get around this error.
推荐答案
考虑:
Sub dural()
Range("A1").Formula = "=" & Chr(34) & "Hello" & Chr(34) & "& A2"
End Sub
这篇关于将包含与号的公式插入单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文