ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   To find number of non-empty cells across columns (https://www.excelbanter.com/excel-programming/333456-find-number-non-empty-cells-across-columns.html)

Mark Stephens[_3_]

To find number of non-empty cells across columns
 
Hi guys,

I regularly use the following code to count the number of occupied rows in a
sheet:

Sheets(1).Cells(Rows.Count, "A").End(xlUp).row

I tried replacing ros with columns and A with 1 but it wont work for columns
(i.e. count the number of non empty cells in row 1).

Anyone know how to convert it into a column counter?

Help much appreciated, kind regards, Mark



Vasant Nanavati

To find number of non-empty cells across columns
 
Sheets(1).Cells(1, Columns.Count).End(xlToLeft).Column

--

Vasant



"Mark Stephens" wrote in message
...
Hi guys,

I regularly use the following code to count the number of occupied rows in
a sheet:

Sheets(1).Cells(Rows.Count, "A").End(xlUp).row

I tried replacing ros with columns and A with 1 but it wont work for
columns (i.e. count the number of non empty cells in row 1).

Anyone know how to convert it into a column counter?

Help much appreciated, kind regards, Mark





All times are GMT +1. The time now is 12:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com