+ Reply to Thread
Results 1 to 16 of 16

HELP WITH ERROR CODE '1004' Application-defined or object defined error

  1. #1
    Registered User
    Join Date
    04-16-2015
    Location
    Scotland
    MS-Off Ver
    2007
    Posts
    40

    HELP WITH ERROR CODE '1004' Application-defined or object defined error

    Hi guys I am doing a uni project and I am having problems with my VBA coding. I got help with the coding from ARowbot on here and he has really been a big help. However for some reason whenever I run my code although it still does what it is meant to do, i still get error code '1004' and it says 'Application-defined or object defined error'. I really do not know how to get rid of the error. the code is shown below

    Please Login or Register  to view this content.
    I have attached the file here below..UNI (F) STOCK TAKE 2015 N M.xlsm

    Thanks guys

    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #3 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer
    Last edited by QuintonMcCloud; 04-20-2015 at 10:44 AM.

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: HELP WITH ERROR CODE '1004' Application-defined or object defined error

    Please use code tags when posting too the Forum. See link Rule No. 3.

    http://www.excelforum.com/forum-rule...rum-rules.html

    Try changing this:

    Please Login or Register  to view this content.
    To this:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    04-16-2015
    Location
    Scotland
    MS-Off Ver
    2007
    Posts
    40

    Re: HELP WITH ERROR CODE '1004' Application-defined or object defined error

    I am really sorry hadnt gone round to reading the rules actually. Thank you so much for doing the tags for me JOHN H. DAVIS. I am gonna try and change the coding as advised and try and see if the error comes up. I will give you feed back .

    thanks again.

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: HELP WITH ERROR CODE '1004' Application-defined or object defined error

    You're welcome. Hope it works for you.

  5. #5
    Registered User
    Join Date
    04-16-2015
    Location
    Scotland
    MS-Off Ver
    2007
    Posts
    40

    Re: HELP WITH ERROR CODE '1004' Application-defined or object defined error

    Hi JOHN yeah that didnt remove the error but didnt corrupt the code or anything. It says the error is coming from the following:

    Sheets("TimberMONTHLY").Range(Cells(5, "E"), Cells(p, i)).Locked = True

    I am still trying to decipher it and figure out where the error is so i can fix it.

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: HELP WITH ERROR CODE '1004' Application-defined or object defined error

    ?. That sheet isn't included in the code posted above.

  7. #7
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: HELP WITH ERROR CODE '1004' Application-defined or object defined error

    Generally you would see that if the sheet with that name doesn't exist (or p / i are out of scope).

    Does that sheet in fact exist with that exact spelling?
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

  8. #8
    Registered User
    Join Date
    04-16-2015
    Location
    Scotland
    MS-Off Ver
    2007
    Posts
    40

    Re: HELP WITH ERROR CODE '1004' Application-defined or object defined error

    Hi GeneralDisarray thank you for your response . JOHN the code is for another page as well but it is the same code as the one pasted above. Basically the workbook has different material types and the vba performs similar tasks on different pages. So in other words the error comes up on the following:

    Sheets("InsulationMONTHLY").Range(Cells(5, "E"), Cells(p, i)).Locked = True

    so you see how it is the same as the TIMBER one that i posted above.

    Apologies for the confusion.

  9. #9
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: HELP WITH ERROR CODE '1004' Application-defined or object defined error

    I can't figure this one out. Hope someone else can jump in and help.

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

    Re: HELP WITH ERROR CODE '1004' Application-defined or object defined error

    You need a sheet reference for Cells.

    So use this,
    Please Login or Register  to view this content.
    or, rather more succinctly, this.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  11. #11
    Registered User
    Join Date
    04-16-2015
    Location
    Scotland
    MS-Off Ver
    2007
    Posts
    40

    Re: HELP WITH ERROR CODE '1004' Application-defined or object defined error

    OMG THANK YOU THANK YOU EVERYONE. Thank you JOHN, GeneralDissaray. NORIE you solved it thank you sooo much the error code does not come up anymore I am sooo grateful guys thank you soo much.. I run the code and it does exactly what I had wanted it to do for such a long time thank you sooo much.

  12. #12
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,097

    Re: HELP WITH ERROR CODE '1004' Application-defined or object defined error

    It looks there is an issue with next statement
    Please Login or Register  to view this content.
    because sheet "INSULATION" is protected, is it?
    - Battle without fear gives no glory - Just try

  13. #13
    Registered User
    Join Date
    04-16-2015
    Location
    Scotland
    MS-Off Ver
    2007
    Posts
    40

    Re: HELP WITH ERROR CODE '1004' Application-defined or object defined error

    HI PCI yes it is and what I wanted to do was that when you clicked save (which essentially the vba i was trying to correct was for a save button macro) the data would be copied from one worksheet and saved onto another so for example from INSULATION to InsulationMONTHLY. However, once pasted i wanted the InsulationMONTHLY column to be protected so that the user will not be able to edit anything on that page. What i am actually still unsure of and yet to see is whether or not at the end of the month the April column will lock and then when the user repeats the same process it will save for the following month. I am trying to ensure that it works that way and just carries forward like that. Because I am not an advanced vba person I am taking it step by step. Any advice PCI ?

  14. #14
    Registered User
    Join Date
    04-16-2015
    Location
    Scotland
    MS-Off Ver
    2007
    Posts
    40

    Re: HELP WITH ERROR CODE '1004' Application-defined or object defined error

    Oh btw PCI i realised i can not run the macro if the pages are protected I would have to embed the protection after the macro has run. So all the pages are unprotected and when i run the macro ammended by NORIE it works perfect and protects after the pasting has been done.

  15. #15
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,097

    Re: HELP WITH ERROR CODE '1004' Application-defined or object defined error

    But for me, one first concern is still to clear the content of sheet "INSULATION" when it is protected.
    Sheet "InsulationMONTHLY" protection is removed to permit to write in, then we need to do the same for sheet "INSULATION"

  16. #16
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,097

    Re: HELP WITH ERROR CODE '1004' Application-defined or object defined error

    OK, you got it

+ 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. VBA ERROR: run time error 1004: Application-defined or Object-defined error in excel 2013
    By AnanthKrishna in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-13-2015, 06:16 AM
  2. Replies: 1
    Last Post: 03-12-2014, 12:42 PM
  3. [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
  4. [SOLVED] Error 1004: Application-defined or object-defined error on Range(Cells(x,y)) syntax
    By winch in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-04-2013, 11:02 AM
  5. Replies: 2
    Last Post: 09-12-2012, 01:01 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