View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Charles Chickering Charles Chickering is offline
external usenet poster
 
Posts: 272
Default row number and column number of cell

Here is a function that will return the last cell as a range, you could
either break the code apart and get what you need or just use the Range.Row
and Range.Column properties.

Function FindLastCell() As Range
Dim LastColumn As Integer
Dim LastRow As Long
Dim LastCell As Range
If WorksheetFunction.CountA(Cells) 0 Then
'Search for any entry, by searching backwards by Rows.
LastRow = Cells.Find(What:="*", After:=[A1], _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
'Search for any entry, by searching backwards by Columns.
LastColumn = Cells.Find(What:="*", After:=[A1], _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
Set FindLastCell = Cells(LastRow, LastColumn)
Else
Set FindLastCell = Range("A1")
End If
End Function

'to use this function call it like this:
Dim lCell As Range
Set lCell = FindLastCell
Row = lCell.Row
Column = lCell.Column

--
Charles Chickering

"A good example is twice the value of good advice."


"Pierre Laporte" wrote:

I need to know in visual basic what is the row number and column number of
the cell that is used with the highest row and column number.

__________________________________________________ ________________ Pierre
Laporte