报价标记VBA [英] Quotation Marks VBA

查看:296
本文介绍了报价标记VBA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个将公式输入单元格的函数。但是我继续收到语法错误。我知道这是引号。我想知道如何在函数中包含公式的引号,而不会引起语法错误。

I'm creating a function that inputs a formula into a cell. But I keep on receiving a syntax error. I know this is due to the quotation marks. I was wondering how I would go about including the quotation marks of the formula in the function without causing a syntax error.

任何帮助都将感激不尽。

Any help would be grateful.

Sub codedump()


      Range("A1").Value = "=Dump(GoogleAnalytics("ga:78770227", "ga:visits", "2014-05-28", "2014-06-26", "","", "", "", 500, FALSE, FALSE))"

End Sub


推荐答案

p>使用转义

例如,给出了引号。否则,使用char代码

For example, "" gives a quotation mark. Otherwise, use char codes

Sub codedump()

      Range("A1").Value = "=Dump(GoogleAnalytics(""ga:78770227"", ""ga:visits"", ""2014-05-28"", ""2014-06-26"", """","""", """", """", 500, FALSE, FALSE))"

End Sub

$ b http: //msdn.microsoft.com/en-us/library/267k4fw5(v=vs.85).aspx

替代方法:

'Escaping
Private Sub InsertQuote()
   TextBox1.Text = "She said, ""You deserve a treat!"" "
End Sub

'Character code
Private Sub InsertAscii()
   TextBox1.Text = "She said, " & Chr(34) & "You deserve a treat!" & Chr(34)
End Sub

'Defined string
Const quote As String = """"
TextBox1.Text = "She said, " & quote & "You deserve a treat!" & quote

这篇关于报价标记VBA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆