VBA-计算一行中填充的单元格数

VBA-计算一行中填充的单元格数,vba,excel,Vba,Excel,以下是到目前为止我的代码。有什么建议吗 With wSheet colCount = .Range(1 & .Columns.Count).End(xlToRight).Column End With 我做错了什么?试试: colCount = wSheet.UsedRange.Rows(1).Columns.Count (修订版)试试: colCount = wSheet.UsedRange.Rows(1).Columns.Count (修订版)获取最右边填充列的

以下是到目前为止我的代码。有什么建议吗

 With wSheet
     colCount = .Range(1 & .Columns.Count).End(xlToRight).Column
  End With
我做错了什么?

试试:

colCount = wSheet.UsedRange.Rows(1).Columns.Count
(修订版)

试试:

colCount = wSheet.UsedRange.Rows(1).Columns.Count

(修订版)

获取最右边填充列的编号:

colCount = .Cells(1, .Columns.Count).End(xlToLeft).Column
要获取非空白单元格的计数,如标题所示:

Application.WorksheetFunction.CountA(.Rows(1).EntireRow.Cells)

要获取最右侧填充列的编号,请执行以下操作:

colCount = .Cells(1, .Columns.Count).End(xlToLeft).Column
要获取非空白单元格的计数,如标题所示:

Application.WorksheetFunction.CountA(.Rows(1).EntireRow.Cells)

看起来你在混合行和列?看起来你在混合行和列?