last column used


Posted by Neil Bhatia on December 20, 2001 4:54 AM

I am trying to get the last column used by excel
I can get the last row used by using

Worksheets(strWorksheet).Range("A65536").End(xlUp).Row

So I thought I would try using

Worksheets(strWorksheet).Range("HZ1").End(xlLeft).Col

However that doesnt work, any help would be much appreciated

Posted by Mudface on December 20, 2001 4:59 AM


Try : -

x = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Columns (or .Rows for the row).

Posted by Mudface on December 20, 2001 5:07 AM

Ooops, that'll give you the value in the cell, try .Column or .Row to return the column or row number.



Posted by Campeius on December 20, 2001 6:26 AM

Range("HZ1").End(xlToLeft).Column