+ Reply to Thread
Results 1 to 6 of 6

Protect Formula in "New Row"

  1. #1
    Registered User
    Join Date
    08-29-2013
    Location
    Wolverhampton, England
    MS-Off Ver
    Excel 2010
    Posts
    43

    Protect Formula in "New Row"

    I have the code:

    Sub Add_New_Row()
    Application.ScreenUpdating = False
    Dim Ws As Worksheet
    Dim Target As Range
    Dim Lrow As Long

    Set Ws = ActiveSheet
    Lrow = Ws.Range("A" & Rows.Count).End(xlUp).Row
    Set Target = Ws.Cells(Lrow, 1)

    Ws.Range(Cells(Target.Row, 1), Cells(Target.Row, 11)).Copy
    Target.Offset(1, 0).PasteSpecial xlPasteFormats, xlPasteSpecialOperationNone

    Ws.Range(Cells(Target.Row, 8), Cells(Target.Row, 11)).Copy
    Target.Offset(1, 7).PasteSpecial (xlFormulas)

    Target.Offset(1, 0).Value = Target + 1
    Target.Offset(2, 0).EntireRow.Insert

    End Sub


    Where a new row is inserted via a "button" on the sheet. What I also need is for the "New Row" to protect the formula included in it to stop anyone from changing those formula.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,685

    Re: Protect Formula in "New Row"

    You'd have to lock the cells (the default) and protect the worksheet with a password to protect the formulae.

    Which implies you'd have to unlock any cells where you want the users to input data.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    08-29-2013
    Location
    Wolverhampton, England
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Protect Formula in "New Row"

    That doeesn't work had already tried that. It stops the VBA code from working.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,685

    Re: Protect Formula in "New Row"

    What VBA Code? If it's just this code, add Ws.Unprotect at the beginning and Ws.Protect at the end.

  5. #5
    Registered User
    Join Date
    08-29-2013
    Location
    Wolverhampton, England
    MS-Off Ver
    Excel 2010
    Posts
    43

    Thumbs up Re: Protect Formula in "New Row"

    Thank you - works perfectly

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,685

    Re: Protect Formula in "New Row"

    You're welcome.

+ 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. [SOLVED] Activate "sorting" feature when worksheets are setup to "password protect" itself
    By nenadmail in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-26-2012, 09:04 PM
  2. Replies: 2
    Last Post: 03-09-2010, 01:25 PM
  3. [SOLVED] Excel 2002 "Protect Sheet", but Allow "Insert Comments"?
    By Dave Peterson in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-06-2005, 06:05 AM
  4. [SOLVED] Excel 2002 "Protect Sheet", but Allow "Insert Comments"?
    By VP Safe in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  5. Excel 2002 "Protect Sheet", but allow "Hide Columns"?
    By VP Safe in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  6. [SOLVED] Excel 2002 "Protect Sheet", but Allow "Insert Comments"?
    By VP Safe in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 AM
  7. Excel 2002 "Protect Sheet", but allow "Hide Columns"?
    By VP Safe in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 PM
  8. [SOLVED] Excel 2002 "Protect Sheet", but Allow "Insert Comments"?
    By VP Safe in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-05-2005, 03:05 PM

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