+ Reply to Thread
Results 1 to 7 of 7

[SOLVED]Run-Time Error 91

  1. #1
    Registered User
    Join Date
    11-15-2010
    Location
    Tulsa, OK
    MS-Off Ver
    Excel 2003
    Posts
    3

    [SOLVED]Run-Time Error 91

    I've done a lot of searching, but to no avail. I'm not real familiar with macros and the one I have is one I found that is close to what I need. I have a workbook with several worksheets. I want to search through each worksheet and have the results posted to a new worksheet. What I have works unless the word I'm searching for doesn't appear on a worksheet and I get the run time error at that point.

    Here is the code:
    Please Login or Register  to view this content.

    The error occurs at:

    Please Login or Register  to view this content.
    Last edited by tcobb64; 11-16-2010 at 11:19 PM. Reason: Added Code Tags

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,263

    Re: Run-Time Error 91

    You need to test the function return:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  3. #3
    Registered User
    Join Date
    11-15-2010
    Location
    Tulsa, OK
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Run-Time Error 91

    That fixed the problem! Thanks for your help. For some reason, though, it duplicates the findings and the new spreadsheet. This is a minor inconvenience though.

  4. #4
    Registered User
    Join Date
    10-13-2010
    Location
    Malvern, AR
    MS-Off Ver
    Excel 2003
    Posts
    49

    Re: Run-Time Error 91

    If you feel that your problem was solved, please change the title of the post to [SOLVED].

    Thanks!

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,263

    Re: Run-Time Error 91

    It should not duplicate anything. What actual code see you using now?

  6. #6
    Registered User
    Join Date
    11-15-2010
    Location
    Tulsa, OK
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Run-Time Error 91

    Here's the code now. What it does is creates a new worksheet and lists the results twice. If that makes sense. Example, I get the results listed lines 1-10 and then repeated lines 11-20.
    Please Login or Register  to view this content.
    Last edited by romperstomper; 11-16-2010 at 04:00 PM. Reason: add code tags

  7. #7
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,263

    Re: Run-Time Error 91

    Your code loops through every sheet which includes your output sheet, which I think is why you are getting the same data twice.

+ 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