在第x行中计算非空白单元格

我试图实现什么是计数行中的非空白单元格。 我在macros的第三行出错。 我不知道如何解决这个问题。

 Sub CountNonEmptyCells() lRow = Cells(Rows.Count, 1).End(xlUp).Row Rows(lRow).SpecialCells(xlCellTypeConstants, 23).Cells.Count MsgBox lRow End Sub 

没关系,我自己解决:

 Sub CountNonEmptyCells() lRow = Cells(Rows.Count, 1).End(xlUp).Row x = Rows(lRow).SpecialCells(xlCellTypeConstants, 23).Cells.Count MsgBox x End Sub