View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Find last used cell in row with blanks inbetween

The trick is to start at IV1 and work backwards:

Function finder(r As Integer) As Integer
For i = 256 To 1 Step -1
If (IsEmpty(Cells(r, i))) Then
Else
finder = i
Exit For
End If
Next
End Function

To use it, set r=to the row of interest and it will return the number of the
first non-empty cell starting from the end!
--
Gary''s Student


"Les Stout" wrote:

Hi, i need to start at cell A1 and find the last used cell in the same
row using code. The only problem is that there are sometimes one or two
blanks in the row.I know i can use - Selection.End(xlToRight).Select
But the problem is that it stops at the blanks too.

Any help with some code would be appreciated.

thanks in advance.

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***