ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to count the number of occupied columns in a sheet? (https://www.excelbanter.com/excel-programming/362648-how-count-number-occupied-columns-sheet.html)

Mark Stephens[_3_]

how to count the number of occupied columns in a sheet?
 
I know how to count rows:

lgLastRow = Workbooks(2).Sheets(pbFundSheetNo).Cells(Rows.Coun t,
"A").End(xlUp).Row

Can the same code be adapted to count the number of used columns?

Thanks, Mark



Norman Jones

how to count the number of occupied columns in a sheet?
 
Hi Mark,

Try:

LastCol = Cells(1, Columns.Count).End(xlToLeft).Column


---
Regards,
Norman



"Mark Stephens" wrote in message
...
I know how to count rows:

lgLastRow = Workbooks(2).Sheets(pbFundSheetNo).Cells(Rows.Coun t,
"A").End(xlUp).Row

Can the same code be adapted to count the number of used columns?

Thanks, Mark





All times are GMT +1. The time now is 02:21 PM.

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