+ Reply to Thread
Results 1 to 2 of 2

Method 'Sort' of object '_Worksheet' failed

  1. #1
    Registered User
    Join Date
    02-25-2015
    Location
    Birmingham, England
    MS-Off Ver
    MS Office 2010
    Posts
    29

    Method 'Sort' of object '_Worksheet' failed

    I have a really annoying problem whereby I can run a macro on one computer, but when running on a different computer I get the above error message.

    Both computers have the same version of excel!

    Below is the section of code that fails.

    Please Login or Register  to view this content.
    it fails on the last line of that code. I have missed out some detail such as the LastRow code as I didn't feel it was relevant.

    Please help!

    Thanks

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

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

    I cannot reproduce this error. When something runs on one computer and not another, there is usually some difference that the user isn't considering, often in the file and having nothing to do with the computers.

    What does the data look like on the active sheet? How is this code being invoked? Are you sure that the intended sheet is active when this code is invoked? One suggestion would be to add a line before the line that fails to confirm the correct sheet:
    Please Login or Register  to view this content.
    Also consider attaching your file, so we can do a better job of troubleshooting. The paper clip icon does not work for attachments. To attach a file, under the text box where you type your reply click the Go Advanced button. On the next screen scroll down and click on Manage Attachments, which will show a pop-up window to Select and Upload a file. Then close the window.

    I have a couple of other observations. These are not causing your problem but you might find them helpful.

    Please Login or Register  to view this content.
    This declaration does not do what you think. In VB, you must specify a data type for each variable, or it will default to Variant. In this declaration, ProductSort is a Range and all the other are Variants. This doesn't cause an error but it would be a better practice to specify the data type intended.
    Please Login or Register  to view this content.
    It is not necessary to Select things to manipulate them. When you Select, it affects the worksheet display, could disorient the user, and takes a lot longer to execute. For example, this
    Please Login or Register  to view this content.
    could be done like this:
    Please Login or Register  to view this content.
    You are using an extra level of indirection to refer to the active sheet. Again, not an error, but might be a little cleaner to do this:

    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Method 'Sort' of object '_Worksheet' failed
    By beasley101 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-02-2019, 08:07 AM
  2. Method 'Range' of object '_Worksheet' failed
    By vbachallenged in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-17-2012, 02:56 PM
  3. Help with method 'Range' of object '_Worksheet' failed
    By Andrew_Harris in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-11-2011, 01:00 PM
  4. XL03 Sort error: "Method 'Range' of object '_Worksheet' failed"
    By AdLoki in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-07-2011, 08:23 AM
  5. Method 'Range' of object '_worksheet' failed
    By wilro85 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-06-2010, 06:24 PM
  6. Method 'Range' of object '_Worksheet' failed
    By JSnow in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-27-2009, 03:55 PM
  7. Replies: 1
    Last Post: 12-07-2005, 07:25 PM

Tags for this Thread

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