Below is some Excel vba code that tries to print the column count of a range that is specified in a 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
2 个解决方案
#1
8
Use
使用
Range(var1a).Columns.Count
范围(var1a).Columns.Count
#2
1
The mistake you did was,
你做的错误是,
you declared 'val1a' but calling 'var1a'.
你声明'val1a'但是叫'var1a'。
correct the typo and you'll be able to get that.
纠正错字,你就能搞定。
#1
8
Use
使用
Range(var1a).Columns.Count
范围(var1a).Columns.Count
#2
1
The mistake you did was,
你做的错误是,
you declared 'val1a' but calling 'var1a'.
你声明'val1a'但是叫'var1a'。
correct the typo and you'll be able to get that.
纠正错字,你就能搞定。