Consulting

Results 1 to 3 of 3

Thread: Run time Error 1004 when assigning cell value

  1. #1

    Run time Error 1004 when assigning cell value

    I have been making some changes to a sheet in my workbook (sheet template) adding in a new section in the worksheet changed event to update the format and unlock cells to allow people to fill in somewhere down the line it was working I'm not sure when, then after a few more changes it started to give me 1004 errors when assigning new values to cells, to the point where when running the sub test in module 4 on the template sheet

    Sub test()
        Range("A1").Value = 0
    End Sub
    gives me a 1004 error

    can anyone tell me why

    _Main_Page.xlsm

  2. #2
    Sorry for bothering everyone, but I seem to keep finding the solution right after I post

    As it turns out I forgot to delete a line

    ActiveSheet.Protect
    In one of the functions I called after deciding to move the Protect and Unprotect to encompass the whole event to simplify coding

    And so the reason for the 1004 error was because it was attempting to assign a value to a locked cell on a protected sheet.

  3. #3
    try manually entering value to Cell A1 of Template worksheet.
    what do you get? is the sheet protected? then unprotect it first before
    you put some values.
    Sub test()
        With ActiveSheet
            .Unprotect
            .Range("A1").Value = 0
            .Protect
        End With
    End Sub

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
  •