Consulting

Results 1 to 7 of 7

Thread: Run time Error on Save Data

  1. #1
    VBAX Regular
    Joined
    Oct 2012
    Posts
    35
    Location

    Run time Error on Save Data

    I have some code in the ThisWorkbook section that runs when the workbook is saved. The code is simple, copies a value from one cell to another. It was working fine, but lately I am getting the Run time error '1004'. Bewlo if the code, the Debug hits the first one.

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)


    'On Save, copy Contex members from Sheet 1 to Sheet 2
    Worksheets("Sheet2").Cells(6, 4).Value = Worksheets("Sheet1").Cells(6, 4).Value
     Worksheets("Sheet2").Cells(7, 4).Value = Worksheets("Sheet1").Cells(7, 4).Value
    End Sub
    Thanks!

  2. #2
    try prefixing the all sheet references with thisworkbook.

  3. #3
    VBAX Regular
    Joined
    Oct 2012
    Posts
    35
    Location
    Thanks Westconn1, but that did not work. Same error still exists when attempting to save the file.

    2014-07-18_8-44-43.jpg

  4. #4
    you haven't changed the sheet names or anything similar?

  5. #5
    VBAX Regular
    Joined
    Oct 2012
    Posts
    35
    Location
    I have not, they are still both names Sheet1 and Sheet2

  6. #6
    can you edit cells in the same sheets by code from other procedures?
    have the sheets been protected?

    test if the error is with sheet1 or sheet2

    does it happen in a new workbook?
    post a copy of the workbook (remove any sensitive information), make sure the error still occurs

  7. #7
    VBAX Regular
    Joined
    Oct 2012
    Posts
    35
    Location
    I fond the issue, the sheet did get protected somehow. Once I unprotected it the code ran fine. Thank you for your help westconn1!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •