+ Reply to Thread
Results 1 to 8 of 8

Application-defined or object-defined error

Hybrid View

  1. #1
    Registered User
    Join Date
    09-19-2012
    Location
    Anaheim, California
    MS-Off Ver
    Excel 2010
    Posts
    22

    Question Application-defined or object-defined error

    Hello All,

    So I am parsing a file comparing sorted names. If the name has special characters like #, its seems to give me an "Application-defined or object-defined error". Is there anyway to stop this from happening without going into the list of names and taking out characters? Below is the code snippet providing the error. Any help would be appreciated. Thanks!

    Do While nameRng = nameRng.Offset(1, 0)
                    Set nameRng = nameRng.Offset(1, 0)
                    z = z + 1 ' Sets z for later
                Loop

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Application-defined or object-defined error

    What is that code meant to do?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    09-19-2012
    Location
    Anaheim, California
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: Application-defined or object-defined error

    Thanks for the post. In the larger scheme I am counting similar names in a row. Its the nameRng comparing to the nameRng below it that will throw the error (if the name below it has a # at the beginning of the name). I have tried changing the column to text to no avail. I don't want to remove the "#". I believe it may be treating the name as a formula, but I'm not sure.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Application-defined or object-defined error

    I'm not sure that's the problem.

    Have you checked the values of all the variables when you get the error?

    If you want to count based on criteria why not use Application.CountIf?

  5. #5
    Registered User
    Join Date
    09-19-2012
    Location
    Anaheim, California
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: Application-defined or object-defined error

    I'm not using Application,CountIf because I am also referencing up to 3 more columns to see if I want to count that name. I have checked all the values (names) and I am positive that it's the "#" at the beginning of the name as the code runs and works perfectly when they are removed.

  6. #6
    Registered User
    Join Date
    09-19-2012
    Location
    Anaheim, California
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: Application-defined or object-defined error

    This may help after some investigation, I believe its a formatting error cause these names are showing up as #NAME?. I believe it's not the "#" but an actual cell error.

  7. #7
    Registered User
    Join Date
    09-19-2012
    Location
    Anaheim, California
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: Application-defined or object-defined error

    Funny thing is, I am not using any formulas in any of the name cells.

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Application-defined or object-defined error

    That might cause problems but I would have expected an error like 'Type mismatch...' rather than the one you describe.

    Where are you referencing the other 3 columns?

    Also, what does namerng refer to?

+ 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] application-defined/object-defined error 1004 when trying to read from or write to cells
    By florin_excel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-30-2012, 08:38 AM
  2. Replies: 2
    Last Post: 09-12-2012, 01:01 PM
  3. Application Defined or Object Defined Error, Command Button and Vlookup Function
    By stevedomer in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-14-2011, 11:20 PM
  4. Application-defined or object-defined error with unshare/share macro
    By rlw in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-23-2007, 07:58 AM
  5. Replies: 3
    Last Post: 07-24-2006, 08:20 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