+ Reply to Thread
Results 1 to 16 of 16

"Runtime error '-2147417848 (80010108)' Method 'find' of object 'Range' failed"

  1. #1
    Registered User
    Join Date
    05-18-2012
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    22

    "Runtime error '-2147417848 (80010108)' Method 'find' of object 'Range' failed"

    Hello,

    I have written the following sub which is called from another "main" sub -

    Please Login or Register  to view this content.

    As you can see, Check_Cals() keeps on running till the phrase "#N/A Requesting Data..." is not found in the defined range 'unionrange1'. Once that happens, it does some calculations, saves and closes the opened file 'Myfile.xlsm' and exits the sub. However, when I run this loop, I'm getting this error for the line -

    Please Login or Register  to view this content.
    error - "Runtime error '-2147417848 (80010108)' Method 'find' of object 'Range' failed".
    Could anyone please guide me why this is happening? And suggest how I can remove this bug?

    Thanks,
    excelworker_1

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,464

    Re: "Runtime error '-2147417848 (80010108)' Method 'find' of object 'Range' failed"

    You say "keeps on running till ...". Does it actually run at all? Or is that what you expect it to do? If it runs, is it the first pass, second pass, third pass, ..., that fails. As it is an iterated routine, is there any residual data that is "clogging up the works"?

    What is populating those ranges that means you need to check and loop?

    Seeing a sample workbook with the code might help with the context.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    05-18-2012
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    22

    Lightbulb Re: "Runtime error '-2147417848 (80010108)' Method 'find' of object 'Range' failed"

    Hi TMS,

    Thanks for the prompt reply. You are right - it doesn't loop through. It runs till the end in the 1st pass and then gets stuck at the 2nd pass. My understanding is it goes into the 'else' loop during 1st pass, assigns p to Nothing and cthen alls "Check_Cals" for the 1st time. When it starts passing through the sub for 2nd pass, something is going wrong there (when p is re-assigned to p = unionrange1.find(....)).

    My aim is the code should run till "#N/A Requesting Data" is not found. For each cell in the range that I've defined in the code, data is being pulled from Bloomberg. And I don't think there is any residual data that is giving the error. Because I checked that independently and that works fine.

    Please guide me accordingly.

    Thanks a lot,
    excelworker_1
    Attached Files Attached Files

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: "Runtime error '-2147417848 (80010108)' Method 'find' of object 'Range' failed"

    Instead of recursively calling your sub, I would suggest something like
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  5. #5
    Registered User
    Join Date
    05-18-2012
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: "Runtime error '-2147417848 (80010108)' Method 'find' of object 'Range' failed"

    Hello romperstomper,

    Maybe a silly question by me, but if you look at my code in the first post, I want to do the calculations, saving, calling of another sub etc. only once when p finally becomes Nothing. I think what you have written is 'do the calculations till p becomes nothing'. Can you suggest how to change that to what I'm aiming at doing?

    Also can you explain what "Set p = unionrange1.FindNext(p)" does exactly?

    Thanks a lot,
    excelworker_1

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: "Runtime error '-2147417848 (80010108)' Method 'find' of object 'Range' failed"

    Quote Originally Posted by excelworker_1 View Post
    I think what you have written is 'do the calculations till p becomes nothing'.
    Why do you think that?

    Also can you explain what "Set p = unionrange1.FindNext(p)" does exactly?
    It repeats the original find operation.

  7. #7
    Registered User
    Join Date
    05-18-2012
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: "Runtime error '-2147417848 (80010108)' Method 'find' of object 'Range' failed"

    I tried what you suggested, and it is not working. This is how I re-oriented the code -

    Set p = unionrange1.Find("#N/A Requesting Data...", LookIn:=xlValues)

    Do Until p Is Nothing

    ' Does some calculations here

    ' Calls another sub
    Call Transfer_To_Main_Sheet

    'saves and closes the file Myfile.xlsm
    Workbooks(MyFile & ".xlsm").Save
    Workbooks(MyFile & ".xlsm").Close

    Set p = unionrange1.FindNext(p)
    Loop

    but it gives a "Runtime error 424 Object required" error. Please guide me.

    Thanks,
    excelworker_1

  8. #8
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: "Runtime error '-2147417848 (80010108)' Method 'find' of object 'Range' failed"

    That is not what I suggested. You should not need to 're-orient' the code I posted. The idea is for the loop to repeat until the "#N/A.." is not found before proceeding with your calculations.

  9. #9
    Registered User
    Join Date
    05-18-2012
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: "Runtime error '-2147417848 (80010108)' Method 'find' of object 'Range' failed"

    Oh ok ok. Now I got what you meant. Will try right away and confirm in a bit if it is working. It is taking a bit of time for Excel to pull the external data.

  10. #10
    Registered User
    Join Date
    05-18-2012
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: "Runtime error '-2147417848 (80010108)' Method 'find' of object 'Range' failed"

    Hello romperstomper,

    I tried what you said, but it does not work. I guess it goes in a perpetual loop because ultimately the excel file(s) get stuck and I have to force-shutdown everything and restart again.

    Please guide me.

    Thanks,
    excelworker_1

  11. #11
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: "Runtime error '-2147417848 (80010108)' Method 'find' of object 'Range' failed"

    Can you just confirm what code you actually tried?

  12. #12
    Registered User
    Join Date
    05-18-2012
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: "Runtime error '-2147417848 (80010108)' Method 'find' of object 'Range' failed"

    I did the exact same thing you suggested. Here is the code -

    Please Login or Register  to view this content.
    I also checked that there is not problem with the stuff after "Loop". The code gets stuck when it goes into the "do until" loop. It doesn't give any error message, but just gets stuck and I have to re-start excel. I also tried changing my range to a smaller scope (just 2 rows) in case it is an issue about 'lot of time required for pulling data'. But even for that, it doesnt work.

    Thanks,
    excelworker_1

  13. #13
    Registered User
    Join Date
    05-18-2012
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: "Runtime error '-2147417848 (80010108)' Method 'find' of object 'Range' failed"

    Just above "Set p = unionrange1.Find("#N/A Requesting Data...", LookIn:=xlValues)" I have -

    Please Login or Register  to view this content.
    Basically, just defining the range "unionrange1".

  14. #14
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: "Runtime error '-2147417848 (80010108)' Method 'find' of object 'Range' failed"

    Perhaps add a calculate there (and let's add an escape route)
    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    05-18-2012
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: "Runtime error '-2147417848 (80010108)' Method 'find' of object 'Range' failed"

    Still not working :-(
    It still goes into a perpetual loop. Btw just realized, shouldn't n be initialized to something? I tried both with and without that...

  16. #16
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: "Runtime error '-2147417848 (80010108)' Method 'find' of object 'Range' failed"

    No, n will default to 0. It should not be a perpetual loop, though you might want to reduce the exit value from 1m. I don't have Bloomberg so cannot actually test what is happening.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1