+ Reply to Thread
Results 1 to 5 of 5

Error 400 when sheet is protected

  1. #1
    Registered User
    Join Date
    05-14-2013
    Location
    Charlotte, NC
    MS-Off Ver
    Office 2013
    Posts
    19

    Error 400 when sheet is protected

    When using the code below it works perfectly with the sheet Not protected but after protecting the sheet it gives (error 400) and opens the VB Editor after pressing the button but it still puts the correct values in the cells. The cells that are used are not locked but other adjacent cells are. I can't figure out why it is giving that error or how to correct it so that it does not give the error with the sheet protected.

    -----------

    Sub Dates()

    Dim i As Integer
    Range("A5").Select
    For i = 1 To 7
    ActiveCell.FormulaR1C1 = "=TODAY() - WEEKDAY(TODAY()*0.2)+" & i
    ActiveCell.Offset(1, 0).Select
    Next i
    Range("A5:A11").NumberFormat = "DDDD ~ m/d/yy"

    End Sub

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Error 400 when sheet is protected

    You code will try to select A12, which won't work if it's locked and the protection disallows selection of locked cell. But there's no need to select:

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

  3. #3
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,526

    Re: Error 400 when sheet is protected

    Does this work?


    Please Login or Register  to view this content.
    Re: You code will try to select A12 (shg)
    Did not notice that.

  4. #4
    Registered User
    Join Date
    05-14-2013
    Location
    Charlotte, NC
    MS-Off Ver
    Office 2013
    Posts
    19

    Re: Error 400 when sheet is protected

    shg - that still gives error 400 when the sheet is protected. I had previously unlocked cell A12 thinking the same thing but still got the error when the sheet was protected.
    Last edited by Master Foo; 07-03-2013 at 04:11 PM.

  5. #5
    Registered User
    Join Date
    05-14-2013
    Location
    Charlotte, NC
    MS-Off Ver
    Office 2013
    Posts
    19

    Re: Error 400 when sheet is protected

    jolivanes - That works perfectly. Thanks Very much.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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