View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jean-Yves[_4_] Jean-Yves[_4_] is offline
external usenet poster
 
Posts: 27
Default Getting the LastRow in ExcelSheet from Word

Works fine with me, but it should retrun at least 1 if cell has data.
Is it really sheet 1 you want to check ?
--
Regards

Jean-Yves Tfelt
Europe


"Jan Kronsell" wrote:

I'm trying to find the last used row in column C in a sheet, using
automation from Word.

I use the following code:


Dim rk As Integer
On Error Resume Next
Set xlapp = GetObject(, "Excel.application")
If Err.Number < 0 Then
Set xlapp = CreateObject("excel.Application")
End If
xlapp.Workbooks.Open FileName:= _
"C:\Documents and Settings\Administrator\Dokumenter\Deltagere.xls"
xlapp.Visible = True
rk = xlapp.activeworkbook.sheets(1).Range("c65536").End (xlUp).Row
It opens the workbook and selects the last used cell in column C, but rk
return a 0 in stead of thec expected 27 in this case. How can I Find the row
number of last used cell in column C?

Jan