View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Mr B[_2_] Mr B[_2_] is offline
external usenet poster
 
Posts: 29
Default Cannot read selected row

I am using Excel 2000 with sp3.

I am attempting to run code from the current workbook and open a second
instance of Excel, add a new workbook, paste in data from a recordset from an
Access database.

All works well until I attempt to read the row for thencurrently selected
cell and store to a variable.

Here is my code:
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Add
Set oSheet = oBook.Worksheets(1)
oSheet.Activate
'next line adds data from open recordset - works well
oSheet.Range("A1").CopyFromRecordset myrs
oSheet.Range("A1").Select
oSheet.Range("A1").End(xlDown).Select
'next line reads row from last active worksheet of workbook where code
'is running from, not from the new workbook
MyEnd = Selection.Row

Any help is appreciated.
--
HTH

Mr B