How to Hide a Formula but Allow Input in Excel – 2 Methods

This is an overview:

How to Hide Formula but Allow Input in Excel

Consider the following bank interest calculator:

You want to allow users to input data in C4:C7, but you don’t want to allow them to change the formulas in C9:C10.

 


Method 1 – Protecting the Excel Worksheet to Hide the Formula but Allow Input

Steps

  • Select C4:C10. You can also select all the formulas in the Excel sheet using the Go To Special command: Press F5 >> Special >> Formulas >> OK.

  • Press CTRL+1 to open the Format Cells dialog box.
  • Check Locked and Hidden.
  • Click OK.

  • Select the cells you want to keep editable. Here, C4:C7.
  • Press CTRL+1 and go to the Protection tab.
  • Keep Locked and Hidden unchecked.
  • Click OK.

  • Select Protect Sheet in the Review tab.

Hide Formula but Allow Input with Protecting Excel Worksheet

  • Enter a password (optional).
  • Check Select locked cells and Select unlocked cells.
  • Click OK.

If you select the cells containing formulas, you won’t see the formula in the formula box.

Hide Formula but Allow Input with Protecting Excel Worksheet

If you try to edit those cells, you will see the following error.

But you can input values in C4:C7, and the results in C9:C10 will be updated.

Read More: How to Hide Formulas from Other Users in Excel


Method 2 – Using a VBA Macro to Hide the Formula but Allow Input

  • Press ALT+F11 to open the Microsoft VBA window.
  • Select Insert >> New Module.

  • Copy the following code:
Sub HideFormulaButAllowInput()

ActiveSheet.Protect Userinterfaceonly:=True, AllowFiltering:=True

Range("C4:C7").Locked = False

End Sub
  • Paste the code in the blank module.
  • Press F5 to run the code.

Hide Formula but Allow Input with Excel VBA

 

 


Download Practice Workbook

Download the practice workbook.


Related Articles


<< Go Back to Hide Excel Formulas | Excel Formulas | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Md. Shamim Reza
Md. Shamim Reza

Md. Shamim Reza, a marine engineer with expertise in Excel and a fervent interest in VBA programming, sees programming as a time-saving tool for data manipulation, file handling, and internet interaction. His diverse skill set encompasses Rhino3D, Maxsurf C++, AutoCAD, Deep Neural Networks, and Machine Learning. He holds a B.Sc in Naval Architecture & Marine Engineering from BUET and has transitioned into a content developer role, generating technical content focused on Excel and VBA. Beyond his professional pursuits,... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo