将变量值插入带有文本 VBA 的单元格
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38379391/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Insert variable value into cell with text VBA
提问by reggie86
I'm trying to insert the number contained by the variable Row4Num -1 into the Active Cell, along with some text, but I can't quite figure out the syntax. Any help would be greatly appreciated-- Thanks!
我试图将变量 Row4Num -1 包含的数字以及一些文本插入到活动单元格中,但我无法弄清楚语法。任何帮助将不胜感激 - 谢谢!
Range("I7").Value = "=""Teams: & "" Row4Num - 1"
回答by Scott Craner
This:
这个:
Range("I7").Value = "Teams: " & Row4Num - 1
When using VBA variables in a String they must be outside the ""and concatenated with &. Everything inside the quotes will be treated as a text string.
在字符串中使用 VBA 变量时,它们必须在""&之外并与 & 连接。引号内的所有内容都将被视为文本字符串。

