+ Reply to Thread
Results 1 to 7 of 7

Method 'Range' of object '_Worksheet' failed

  1. #1
    Registered User
    Join Date
    03-25-2009
    Location
    Ann Arbor, MI
    MS-Off Ver
    Excel 2003
    Posts
    4

    Method 'Range' of object '_Worksheet' failed

    I have an interesting error that only happens when there is one row of data in the worksheet (sheet2 or "Half Payout"). Rows 1 & 2 are headers, row 3 is when the data starts - if any. With either no rows of data or more than one the coding works just fine. Here is the exact error message I'm getting: Run-time error '1004': Method 'Range' of object '_Worksheet' failed.

    The following code is supposed to sort the rows of data when opened and then activate the first open cell below B2.
    Please Login or Register  to view this content.
    I appreciate any help on this. Long time searcher/first time poster.
    Last edited by JSnow; 03-27-2009 at 03:54 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Method 'Range' of object '_Worksheet' failed

    If there's only one row of data, gotorow points to one row beyond the end of the spreadsheet. Try it manually.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    03-25-2009
    Location
    Ann Arbor, MI
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Method 'Range' of object '_Worksheet' failed

    Hmmm, I thought something like was happening. When I enter the code after the error and hover over the "gotorow" variable it gives me something like "row=65537".

    I'd love to know WHY this is happening; however, I found a workable solution by pointing the range to B2 if B3 is not blank.

    Please Login or Register  to view this content.
    Thanks so much for the near immediate feedback.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Method 'Range' of object '_Worksheet' failed

    I'd love to know WHY this is happening;
    That's why I suggested you try it manually. Select some cell with nothing below it and do Shift+Down (which is equivalent to what you're doing in code) -- it goes to the last row of the sheet.

  5. #5
    Registered User
    Join Date
    03-25-2009
    Location
    Ann Arbor, MI
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Method 'Range' of object '_Worksheet' failed

    I'm not familiar with the manual method (I'm a newbie that reads alot). I clicked on open cell in column B and held Shift+Down; it highlighted the cell below - it didn't go all the way to the end row. Regardless, I appreciate your time shg.

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Method 'Range' of object '_Worksheet' failed

    (I'm a newbie that reads alot)
    Stick around, we'll fix that (the newbie part -- do continue to read ...)

    Would you please mark the thread as Solved?

    Click the Edit button on your first post in the thread

    Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes

  7. #7
    Registered User
    Join Date
    03-25-2009
    Location
    Ann Arbor, MI
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Method 'Range' of object '_Worksheet' failed

    Thanks, shg. I was wondering how to mark it solved. Apparently I need to reread the forum FAQs here.

+ 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