+ Reply to Thread
Results 1 to 12 of 12

Run-time error '1004': Application-define or object define error

  1. #1
    Registered User
    Join Date
    03-12-2014
    Location
    Tonga
    MS-Off Ver
    Excel 2007
    Posts
    10

    Run-time error '1004': Application-define or object define error

    Someone Please help me to fix this error. everytime i run my code its come up with this error (Run-time error '1004': Application-define or object define error), and its always highlight line #9 (Sheets.Add.Name = rcell.Value) on my code. My working files in on excel 2007 and its contain 87150 rows and 17 columns (A-Q)... Please view my code below.

    Please Login or Register  to view this content.

    Thank You

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

    Re: Run-time error '1004': Application-define or object define error

    Does rcell contain a value that's valid for a sheet name?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    03-12-2014
    Location
    Tonga
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Run-time error '1004': Application-define or object define error

    Thank you Norie for reply....Yes all rcell value is valid.... they're all number with 6 digits.

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

    Re: Run-time error '1004': Application-define or object define error

    No duplicates, no blanks, no errors?

  5. #5
    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: Run-time error '1004': Application-define or object define error

    As Norie suggests, my first thought is a duplicate, which would cause that error. You are checking that the current cell is different than the cell in the immediately previous row, but it could be the same as some other cell in an earlier row.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  6. #6
    Registered User
    Join Date
    03-12-2014
    Location
    Tonga
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Run-time error '1004': Application-define or object define error

    it has some duplication data on the first column (ID) ... no other errors and no blanks

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

    Re: Run-time error '1004': Application-define or object define error

    Any duplicate would cause the error, and like Jeff says you are only checking if the cell above rcell is a duplicate, you aren't checking any other cells.

  8. #8
    Registered User
    Join Date
    03-12-2014
    Location
    Tonga
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Run-time error '1004': Application-define or object define error

    so how am i gonna check any other cells with my code,, please

  9. #9
    Registered User
    Join Date
    03-12-2014
    Location
    Tonga
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Run-time error '1004': Application-define or object define error

    My code is working fine with this sample files (maka2)..but when my file grow up to 87150 rows the error comes up.
    Attached Files Attached Files

  10. #10
    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: Run-time error '1004': Application-define or object define error

    The real way to solve this first must consider what you want to do when you encounter a number and there is already a sheet named using that number. What do you want to happen in that case?

    A simple but unsophisticated way to solve this is by sorting your data on column A. Then your code will work.

    Another way is to ignore errors, adding the lines shown to your existing code. If an error occurs creating a new sheet (most likely because of a duplicate), the code skips trying to copy the row of values, and simply keeps going. I have tested this.

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    03-12-2014
    Location
    Tonga
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Run-time error '1004': Application-define or object define error

    Still not working

  12. #12
    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: Run-time error '1004': Application-define or object define error

    Attach a file that exhibits the error. If it's large, store it to a zip file before attaching.

+ 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] Error " Run-time error '1004': application defined or object defined error
    By lengwer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-11-2013, 07:26 AM
  2. Run-time error "1004" Application defined or object-define-error
    By josros60 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-21-2013, 01:14 PM
  3. error 1004 application define or object define
    By jay11 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-11-2011, 04:09 AM
  4. Define:Run-time error '1004'
    By Johnyue in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-03-2007, 12:41 AM
  5. [SOLVED] run-time error '1004': Application-defined or object-deifined error
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-10-2005, 05:05 PM

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