+ Reply to Thread
Results 1 to 15 of 15

Am I going crazy? Simple thing not working error 1004

  1. #1
    Registered User
    Join Date
    08-16-2013
    Location
    Houston, US
    MS-Off Ver
    Excel 2007
    Posts
    22

    Am I going crazy? Simple thing not working error 1004

    Hello,

    So I have the simplest line not working. The sheet name is right and what I am copying is a formula that I will be doing a paste special with. It works on another sheet. Why on earth is this returning a application-defined or object defined error 1004?

    Please Login or Register  to view this content.
    Thank you so much for your help. Have a nice day.

    -Rob

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Am I going crazy? Simple thing not working error 1004

    Nothing wrong with that line, but if you are trying to copy and paste, you should have two separate lines, one for the copy line and second for the paste line.

  3. #3
    Registered User
    Join Date
    08-16-2013
    Location
    Houston, US
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Am I going crazy? Simple thing not working error 1004

    I'm just posting the line that doesn't work. When I do this on another workbook it works fine and I can paste manually the select

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Am I going crazy? Simple thing not working error 1004

    Could you please the entire code? I tested it and did not get any error.

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,261

    Re: Am I going crazy? Simple thing not working error 1004

    Hi Colbert,

    Try using a named range in your code, like:

    Range("MyRange")
    instead of:
    Range(Cells(6, 2), Cells(35, 2))
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  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: Am I going crazy? Simple thing not working error 1004

    Quote Originally Posted by CobertRannon View Post
    Why on earth is this returning a application-defined or object defined error 1004?

    Please Login or Register  to view this content.
    Because both of the Cells objects refer to cells on the active worksheet.

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  7. #7
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Am I going crazy? Simple thing not working error 1004

    Or fully qualify your cell references, currently they're working on the active sheet

  8. #8
    Registered User
    Join Date
    08-16-2013
    Location
    Houston, US
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Am I going crazy? Simple thing not working error 1004

    Wow,

    I don't know why this took so long but the last comment worked by my using

    Please Login or Register  to view this content.
    This seemed like it was way too hard. I should be able to refer to another sheet with just one declaration of the name of the sheet but as long as it works as I am getting close to a deadline. Thank you for the responses.

  9. #9
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Am I going crazy? Simple thing not working error 1004

    That's what shg's code does

  10. #10
    Registered User
    Join Date
    08-16-2013
    Location
    Houston, US
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Am I going crazy? Simple thing not working error 1004

    The thing as well is that it easily works with the A1 notation but I need to have this in cells format so I can use numbers for row references.... Why was this so much harder with cells formatting?

  11. #11
    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: Am I going crazy? Simple thing not working error 1004

    It's no harder; Cells, like Range, refers to the active worksheet if not qualified.

  12. #12
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Am I going crazy? Simple thing not working error 1004

    It's not to do with cells formatting it's to do with implicit references. Whenever you write Range or Cells etc without specifying the object (which sheet it is) Excel assumes you want to use the active sheet, so your code actually does this:
    Please Login or Register  to view this content.
    When you pass a string ("A1" for example) to the Range function, that isn't the same as passing cells - cells are objects.

  13. #13
    Registered User
    Join Date
    08-16-2013
    Location
    Houston, US
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Am I going crazy? Simple thing not working error 1004

    Thank you so much for the clarification. I really thought I was going crazy with this one. I understand fully now.

    Have a nice day everyone.

  14. #14
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,261

    Re: Am I going crazy? Simple thing not working error 1004

    @shg,

    I went crazy many times with this problem and I needed your answer back then to keep my sanity. Great ANSWER!!!

  15. #15
    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: Am I going crazy? Simple thing not working error 1004

    The one fillip, Marvin, is that Range need not be qualified if the two corner cells are, e.g., this is fine:

    Please Login or Register  to view this content.
    As Kyle points out, though, you need to qualify if the first cell is a string reference, though:

    Please Login or Register  to view this content.

+ 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. CSV file export - a crazy thing happens ... for no reason!
    By kaligad in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 01-03-2013, 07:57 AM
  2. Replies: 3
    Last Post: 05-29-2012, 07:54 AM
  3. [SOLVED] Get Run-Time Error 1004 With Simple Macro
    By One-Eyed Enos in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-22-2012, 01:46 PM
  4. Run time error 1004-some pretty simple VBA.
    By garyi in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-12-2011, 02:11 PM
  5. [SOLVED] HEEEEEEEEEELP!! This thing is driving me crazy.
    By Esaam in forum Excel General
    Replies: 1
    Last Post: 01-22-2006, 06:30 AM

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