vba 查找范围的列数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12647733/
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
Finding columns count of a range
提问by K17
Below is some Excel VBA code that is supposed to print the column count of the range that is specified in the string. I am getting an error in the Debug.Print
section. What am I doing wrong?
下面是一些 Excel VBA 代码,用于打印字符串中指定范围的列数。我在该Debug.Print
部分中遇到错误。我究竟做错了什么?
Dim val1a As String
val1a = "A1:D1"
Dim Rng1 As Range
Debug.Print Rng1(var1a).Columns.Count ' error here
回答by chris neilsen
Use
用
Range(var1a).Columns.Count
回答by Christopher
The mistake you did was,
你犯的错误是,
you declared 'val1a' but calling 'var1a'.
您声明了“val1a”但调用了“var1a”。
correct the typo and you'll be able to get that.
更正错字,你就可以得到它。