Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba 访问范围中的特定列_Vba_Excel_Range - Fatal编程技术网

Vba 访问范围中的特定列

Vba 访问范围中的特定列,vba,excel,range,Vba,Excel,Range,我试图访问特定范围内的第2列,然后计算其中包含常量的单元格。现在我要访问的是范围,但不是范围中的特定列,而是整个范围。。。因此,计算太多的常数 X = Range("MAIN_LIST").Cells.SpecialCells(xlCellTypeConstants).Count 是否有办法访问此范围内的特定列?我试图以某种方式做到这一点: X = Range("MAIN_LIST").Column(2).Cells.SpecialCells(xlCellTypeConstants).Coun

我试图访问特定范围内的第2列,然后计算其中包含常量的单元格。现在我要访问的是范围,但不是范围中的特定列,而是整个范围。。。因此,计算太多的常数

X = Range("MAIN_LIST").Cells.SpecialCells(xlCellTypeConstants).Count
是否有办法访问此范围内的特定列?我试图以某种方式做到这一点:

X = Range("MAIN_LIST").Column(2).Cells.SpecialCells(xlCellTypeConstants).Count
但是我得到了一个语法错误。有人知道具体的语法吗

谢谢。

试试看:

Range("MAIN_LIST").Columns(2).SpecialCells(xlCellTypeConstants).Count
方法是
,而不是


另外,虽然这不是一个错误:使用方法
Cells
是多余的/不必要的,但是
范围
对象本身已经由其
单元格组成,同样,该范围内的任何特定列也由其
单元格组成
:)

我不是肯定的,但是是您编写的
而不是
的语法错误吗?谢谢David。快速提问:既然它告诉我列的格式是Column(RowIndex,ColumnIndex),那么它应该是Columns(,2)吗?我认为intellisense在这方面是错误的。你绝对不能给它传递两个会引起错误的参数。