Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default Trouble reading to object

Hi! I have a sub that opens a workbook. I then try to read values from this
workbook. However I get the error: 1004 Program or obect defined error at the
very end of the code. What is wrong here? Please help me out!

Public Sub readFile() 'secID As String
Dim i As Integer
Dim j As Integer
Dim iNrOfIns As Long
Dim secID As String
secID = "Hej på dig"
Dim str As String
Workbooks.Open "X:\SCD_RiskManager_Pos\RMDBII\test.xls"
Workbooks("test.xls").Activate
Dim oFxOptionsFile As Object
Set oFxOptionsFile =
Workbooks(ActiveWorkbook.Name).Sheets(ActiveSheet. Name)

oFxOptionsFile.Range("A2").Activate
iNrOfIns = oFxOptionsFile.Range(ActiveCell,
ActiveCell.End(xlDown)).Rows.Count




For i = 2 To 10
str = oFxOptionsFile.Cells(i, 0)



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Trouble reading to object

Arne,

There is no 0th column:

str = oFxOptionsFile.Cells(i, 0)

should be (for column A)
str = oFxOptionsFile.Cells(i, 1)


for column B:
str = oFxOptionsFile.Cells(i, 2)

HTH,
Bernie
MS Excel MVP


"Arne Hegefors" wrote in message
...
Hi! I have a sub that opens a workbook. I then try to read values from this
workbook. However I get the error: 1004 Program or obect defined error at the
very end of the code. What is wrong here? Please help me out!

Public Sub readFile() 'secID As String
Dim i As Integer
Dim j As Integer
Dim iNrOfIns As Long
Dim secID As String
secID = "Hej på dig"
Dim str As String
Workbooks.Open "X:\SCD_RiskManager_Pos\RMDBII\test.xls"
Workbooks("test.xls").Activate
Dim oFxOptionsFile As Object
Set oFxOptionsFile =
Workbooks(ActiveWorkbook.Name).Sheets(ActiveSheet. Name)

oFxOptionsFile.Range("A2").Activate
iNrOfIns = oFxOptionsFile.Range(ActiveCell,
ActiveCell.End(xlDown)).Rows.Count




For i = 2 To 10
str = oFxOptionsFile.Cells(i, 0)





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create my own Class Object for Ranges, having trouble assigning name property [email protected] Excel Programming 4 November 29th 05 06:08 PM
Confusion about how the Window object fits into the Excel object model Josh Sale Excel Programming 11 April 15th 05 06:08 PM
trouble finding object to use Wazooli Excel Programming 4 February 22nd 05 01:07 AM
Advice on Reading the Object Browser Kim Excel Programming 2 November 24th 04 10:32 PM
trouble returning a workbook level Name object Brian Murphy Excel Programming 32 May 12th 04 07:47 AM


All times are GMT +1. The time now is 12:06 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"