ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How can I get the last used column in a sheet??? (https://www.excelbanter.com/excel-programming/291574-how-can-i-get-last-used-column-sheet.html)

monika

How can I get the last used column in a sheet???
 

How can I get the last used column in a sheet???

Rob van Gelder[_4_]

How can I get the last used column in a sheet???
 
There's an example on the "Last Row/Col in Worksheet" page on my website

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"monika" wrote in message
...

How can I get the last used column in a sheet???




patrick molloy

How can I get the last used column in a sheet???
 
One might use the UsedRange property of the worksheet.
This is the range that has been used, but is only
refreshed on saving & re-opening. It is useful though.

The UsedRange has two properties. Columns.Count and
Rows.Count that return the UsedRange width and
height...ie columns and rows. BUT you need to know where
the UsedRange starts, so you'll need the Column and Row
values too.

So, on a spreadsheet...

With Activesheet.usedRange
LastRowUsed = .Row + .Rows.Count -1
LastColumnUsed = .Column +.Columns.Count -1
End With

Patrick Molloy
Microsoft Excel MVP



-----Original Message-----

How can I get the last used column in a sheet???
.



All times are GMT +1. The time now is 05:03 AM.

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