+ Reply to Thread
Results 1 to 4 of 4

Previously working code is now is now giving Application-defined or object-defined error

  1. #1
    Registered User
    Join Date
    08-12-2013
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    1

    Question Previously working code is now is now giving Application-defined or object-defined error

    Hi all! I'm by no means an excel programming expert, so I've been unsuccessful in figuring out why my code that has always worked flawlessly is now unhappy...
    I have a sheet called "Preparation" that has a table (columns A-L) and a few command buttons that automatically sort the table based on the desired column. One button that has stopped working sorts my table based on the date column (which is column K in this case). The button is called DateSort.
    To construct the code for this button, I basically just recorded a macro and pasted that code into the sheet it pertains to. The code is extremely basic and has never given me problems. Now when I run it I get the 'Application-defined or object-defined error'. The .Apply line is highlighted.

    One thought I had was I recently updated my machine from MS Office 2007 to 2013. I'm almost positive it was working at some point after the upgrade, but not 100%. Is there a reason the upgrade would cause the error? A setting that needs to be changed in options? Any help would be greatly appreciated!

    I have uploaded a sample workbook, or here is the code located in Sheet1 (Preparation):

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by ready2learn; 05-06-2014 at 07:17 PM. Reason: Added a sample workbook to demonstrate error. Added code tags.

  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,472

    Re: Previously working code is now is now giving Application-defined or object-defined err

    Hi and welcome to the forum.

    Two suggestions: 1) add code tags to your post before a moderator picks it up and 2) upload a sample workbook so the code, and the fault, can be tested.

    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
    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,472

    Re: Previously working code is now is now giving Application-defined or object-defined err

    You need to add [Code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/Code] after your code.

    Because ...

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

  4. #4
    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,472

    Re: Previously working code is now is now giving Application-defined or object-defined err

    Works for me (in 2007) but the code could be a little more efficient:

    Please Login or Register  to view this content.

    I've commented out some parameters that are default options.

    And you should change the properties of the button so that it doesn't move and size with cells ... or it can change shape and font size


    See the updated example


    Is there a reason the upgrade would cause the error?
    Quite possibly but who knows what. Let's put it this way: I developed some code for a client in Excel 2007 and it ran perfectly, and quite quickly. When he ran it in Excel 2010 it took 40 times longer. That was down to Conditional Formatting on one of the sheets. I amended the code to clear the CF before the routine and re-apply it afterwards and it resolved the problem.

    Sometimes, errors are highlighted that bear no relation to the actual problem. Check the references and make sure you don't have any flagged as MISSING.


    Regards, TMS
    Attached Files Attached Files

+ 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. [SOLVED] VBA Application-defined or Object-defined error on an unknown line of code.
    By kyleg222 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-27-2012, 10:19 AM
  2. Pivot Cache VBA code - Application-defined or Object Defined error
    By 4am in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-28-2011, 02:21 PM
  3. Why doesn't working? Application-defined or object-defined error
    By SupperDuck in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-07-2006, 11:00 AM
  4. [SOLVED] Application-Defined or Object-Defined Error on simple code
    By Fid in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-21-2005, 04:05 PM
  5. [SOLVED] Application-Defined or Object-Defined Error on simple code
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-22-2005, 05:06 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