+ Reply to Thread
Results 1 to 5 of 5

protecting formula in cell?

  1. #1
    Registered User
    Join Date
    11-13-2017
    Location
    Raleigh, NC
    MS-Off Ver
    2011
    Posts
    23

    protecting formula in cell?

    I have a spreadsheet the has a 'dummy' row at the top that contains some blank cells and some cells with formulas.
    I have a macro that copies this row and adds it underneath to make new rows that of course, contain the formulas.
    Unfortunately when the user then fills in the rows they sometimes make a mistake and then go back and delete information from a cell and then the formula is gone. Is there a way to 'protect' the formula so that it can be copied and pasted by the the macro but not deleted by the user?

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: protecting formula in cell?

    You should first format the cells with formulas to be locked, and the cells that allow user input are unlocked. Then protect the sheet.

    Your code will then unprotect the sheet, do the copy and paste, and then protect the sheet. The exact code to do this depends on what sheet your data is in, what module your code is in, and how you invoke the macro.

    (By the way I have a workbook that does this and my "dummy" row is on a different sheet that is hidden so as not to distract the user.)
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    11-13-2017
    Location
    Raleigh, NC
    MS-Off Ver
    2011
    Posts
    23

    Re: protecting formula in cell?

    6stringjazzer,
    Thanks so much for the reply. So.....I'm a real beginner and self taught myself macros through YouTubes and with assistance from some great responders here.

    So having said that....I'm not sure how to lock cells and protect sheets but I'm sure I can figure it out. Fixing the code is anothe story.

    I'm going to put the code below and maybe you can show me how to unprotect and reprotect the SOLD sheet in the code? (I call the macro with a 'button' titled UPDATE from the ITEMS sheet. It then moves items from the ITEMS sheet to the SOLD sheet by copying the dummy row at the top of the SOLD sheet and inserting the data from the ITEMS sheet.

    Here's what the macro code looks like.....
    #
    Please Login or Register  to view this content.
    #

    THANKS!
    Last edited by 6StringJazzer; 06-18-2019 at 04:21 PM.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: protecting formula in cell?

    To add CODE tags, select your code and then click the # icon above the edit window. Do not actually type # into your post.

    Or simply type in the tags:

    [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code]

  5. #5
    Registered User
    Join Date
    11-13-2017
    Location
    Raleigh, NC
    MS-Off Ver
    2011
    Posts
    23

    Re: protecting formula in cell?

    6stringjazzer,
    Thanks so much for the reply. So.....I'm a real beginner and self taught myself macros through YouTubes and with assistance from some great responders here.

    So having said that....I'm not sure how to lock cells and protect sheets but I'm sure I can figure it out. Fixing the code is anothe story.

    I'm going to put the code below and maybe you can show me how to unprotect and reprotect the SOLD sheet in the code? (I call the macro with a 'button' titled UPDATE from the ITEMS sheet. It then moves items from the ITEMS sheet to the SOLD sheet by copying the dummy row at the top of the SOLD sheet and inserting the data from the ITEMS sheet.

    Here's what the macro code looks like.....
    Please Login or Register  to view this content.
    Thanks!

+ 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. Protecting cells upon data entry and not protecting the sheet.
    By Acousticlife81 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-06-2017, 10:37 AM
  2. Protecting a cell after data entry without protecting sheet
    By Acousticlife81 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-05-2017, 12:58 PM
  3. [SOLVED] Protecting Cell Format but allowing cell data entry
    By telcocook in forum Excel General
    Replies: 3
    Last Post: 10-10-2014, 04:06 PM
  4. Autolocking cell after entering number and protecting the cell from editing
    By batya in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-08-2014, 06:22 AM
  5. Excel 2007 : Protecting the formula
    By sushil10s in forum Excel General
    Replies: 1
    Last Post: 01-24-2012, 06:13 AM
  6. Protecting a formula
    By Kim in forum Excel General
    Replies: 1
    Last Post: 06-27-2006, 01:55 PM
  7. Protecting Formula's
    By MABeatty in forum Excel General
    Replies: 3
    Last Post: 03-22-2006, 02:10 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