On Sat, 30 Jul 2005 20:28:03 -0500, ajocius
wrote in
microsoft.public.excel.programming:
How can I find the last cell in a row? I have this spreadsheet
that has approximately 1500 rows. Each row has a different last
column. The columns in a row can vary between 5 to 52. I want the
value to be saved in a Variable. Your help can make this weekend go
smoother.
There are probably a few different methods to find the last column in a
row. Here's one:
Dim lngNRows As Long
Dim lngNCols As Long
Dim i As Long
lngNRows = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell) .Row
For i = 1 To lngNRows
lngNCols = Cells(i, 256).End(xlToLeft).Column
Debug.Print "Row " & i & " has " & lngNCols & " column(s)."
Next i
This will not distinguish between rows where column "A" is empty or not
- the answer is "1".
--
Michael Bednarek
http://mbednarek.com/ "POST NO BILLS"