+ Reply to Thread
Results 1 to 16 of 16

Is there a way to protect a formula?

  1. #1
    Registered User
    Join Date
    05-29-2015
    Location
    Painesville, OH
    MS-Off Ver
    2007
    Posts
    23

    Is there a way to protect a formula?

    We have a worksheet with two columns that contain formulas that are dependent on each other because this is how orders are placed.

    If a customer orders cartons of an item, then we enter the carton quantity in column F and it calculates eaches in column G, but often a customer orders eaches we enter the eaches quantity in column G which calculates the quantity of cartons in column F. An order very often will contain a combination of cartons and eaches. This adds up cartons, eaches, and numerous other things to create an estimate of weights and measures for shipping purposes. (See attached example).

    (Yes...I know this creates a circular reference but I've already allowed for iterations)

    The problem is that the user often puts a quantity in the wrong column thus wiping out the formula. Is there a way to delete/change a quantity without affecting the formula?

    Thanks in advance!!!
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    08-06-2015
    Location
    England
    MS-Off Ver
    2013
    Posts
    68

    Re: Is there a way to protect a formula?

    In your spreadsheet, all the cells are locked except the ones with formulas in them. Why not lock the ones with formulas in them?

  3. #3
    Registered User
    Join Date
    05-29-2015
    Location
    Painesville, OH
    MS-Off Ver
    2007
    Posts
    23

    Re: Is there a way to protect a formula?

    Because protecting the sheet will protect the formula but also prevent us from entering quantities.

    Thank you!

  4. #4
    Registered User
    Join Date
    08-06-2015
    Location
    England
    MS-Off Ver
    2013
    Posts
    68

    Re: Is there a way to protect a formula?

    Well you already have a Ctn Qty in column F in the spreadsheet. Isn't that where you input the quantity? That column can be unlocked (select column, press CTRL+1, go to the Protection tab and make sure "Locked" is not checked).
    There is no way to have a cell with a formula in it, then type over the formula in the cell and still have a formula.
    One workaround is if you make your table into an actual table (Insert->Table). Add any formulas you need and make sure they apply to the entire column (after you type the formula in and press ENTER, it should prompt you to select this). This way, any new lines you add to the table will have the formula applied automatically, even if some previous lines have hard coded data (so if you added Item 5 in your cell A7, line 7 will also be incorporated in the table, meaning any formulas applied to the column will appear in the new line; a user can type over a formula but a new line would still have the formulas applied). Not sure if that makes sense to you or if it's what you want. Your description says you have formulas in columns F and G but your spreadsheet shows G is completely blank so I am confused.

  5. #5
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Is there a way to protect a formula?

    No, since you are allowing users to manually enter values into those two columns (D and E in your example), it will automatically overwrite the formula. If the user makes a mistake and puts in units instead of cartons, then the only option is UNDO. The other option is to use VBA to reenter the formula whenever the cell is blank.
    (that would require that the user enable macros).
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  6. #6
    Registered User
    Join Date
    05-29-2015
    Location
    Painesville, OH
    MS-Off Ver
    2007
    Posts
    23

    Re: Is there a way to protect a formula?

    My mistake; column G has a formula so sorry for the confusion! So there is no way to protect a formula in a cell so that if the value entered is deleted then the formula reappear? Just trying to "idiot proof" this darn thing.

    Thank you!

  7. #7
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    846

    Re: Is there a way to protect a formula?

    Hi,how about using the attached sheet?
    When you open it, you'll see 3 coloured areas, the password for each area is just under it.
    The sheet has 3 areas of protection in 2 layers.

    Layer 1 - Individual locked ranges
    layer 2 - Overall sheet protection

    Area 1 - Purple - locked, password set as 'Test'
    Area 2 - Blue - locked, password set as 'Test2'
    Area 3 - Orange - locked, password set as 'Test3'

    The sheet is something i came up with a long time ago and posted it on this forum (somewhere)

    See if it helps.

    Rich
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    05-29-2015
    Location
    Painesville, OH
    MS-Off Ver
    2007
    Posts
    23

    Re: Is there a way to protect a formula?

    Quote Originally Posted by ChemistB View Post
    The other option is to use VBA to reenter the formula whenever the cell is blank.
    (that would require that the user enable macros).
    Well, we can do this! Just am not a VBA person but know enough to be dangerous . Can you help with this?

    Thank you!

  9. #9
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    846

    Re: Is there a way to protect a formula?

    If it does work for you, then view the code within 'This Workbook'
    For anyoen wanting the code without downloading, see below:
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    08-06-2015
    Location
    England
    MS-Off Ver
    2013
    Posts
    68

    Re: Is there a way to protect a formula?

    Personally, having to idiot proof my own spreadsheets, I think data validation might be an option. Have a cell where the user can type the value and an adjacent cell with data validation where the user needs to select what type of value they typed (carton, gallons, unicorns, whatever you want). You could have another set of cells like these if you need and then you can have a separate cell with a formula based on these 4 cells. Protect the formula cell and voila.

  11. #11
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Is there a way to protect a formula?

    Have not looked at your file, but could you perhaps have 2 different columns - 1 for each and 1 for cartons, then base everything of those?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  12. #12
    Registered User
    Join Date
    05-29-2015
    Location
    Painesville, OH
    MS-Off Ver
    2007
    Posts
    23

    Re: Is there a way to protect a formula?

    Not an option for us.

    Thank you!

  13. #13
    Registered User
    Join Date
    05-29-2015
    Location
    Painesville, OH
    MS-Off Ver
    2007
    Posts
    23

    Re: Is there a way to protect a formula?

    Quote Originally Posted by ChemistB View Post
    substitute commas with semi-colons if your region settings requires
    Not an option for us. Not even clear what this would do....

  14. #14
    Registered User
    Join Date
    05-29-2015
    Location
    Painesville, OH
    MS-Off Ver
    2007
    Posts
    23

    Re: Is there a way to protect a formula?

    THANK YOU EVERYONE!!! REALLY GREAT IDEAS!! Going to work on a few of these to see what would work best. I always learn something new from you guys and I truly appreciate it!

  15. #15
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Is there a way to protect a formula?

    Quote Originally Posted by OmegaSea View Post
    Not an option for us.

    Thank you!
    Can I ask why?

  16. #16
    Registered User
    Join Date
    05-29-2015
    Location
    Painesville, OH
    MS-Off Ver
    2007
    Posts
    23

    Re: Is there a way to protect a formula?

    Quote Originally Posted by FDibbins View Post
    Can I ask why?
    Wouldn't the network administrator have to make a global change? Getting management to ok this would be a NIGHTMARE of biblical proportions.

+ 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. Excel 2013 - Protect Range of Cells without using Protect Sheet Button
    By caf20012 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 09-23-2014, 04:50 AM
  2. Replies: 2
    Last Post: 03-21-2014, 11:43 AM
  3. Replies: 2
    Last Post: 01-17-2013, 08:39 AM
  4. How to protect formula & macro protect without password ?
    By nur2544 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-26-2012, 05:24 AM
  5. Replies: 2
    Last Post: 07-02-2010, 02:40 PM
  6. [SOLVED] Passwords Disappear in OpenOffice (Protect Worksheet, and Protect Workbook)
    By msnews.microsoft.com in forum Excel General
    Replies: 6
    Last Post: 12-27-2005, 04:20 AM
  7. Replies: 2
    Last Post: 07-16-2005, 11:05 AM

Tags for this Thread

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