Home » excel » Hiding the formula bar in Excel for a specific file

Hiding the formula bar in Excel for a specific file

Posted by: admin March 9, 2020 Leave a comment

Questions:

I would like to hide the formula bar in a specific Excel file and only in this file. I know we can do it with VBA (Application.DisplayFormulaBar = False) but I am wondering if there is another solution like editing the CustomUI file.

Usually I edit the CustomUI file for hiding ribbon, adding custom tabs, … It would be nice if we can hide the formula bar in this way.

Any suggestions?

Thanks.

How to&Answers:

Short answer is: No, you cannot.

Unfortunately, you cannot hide it by editing the CustomUI file. The formula bar has to be hidden using VBA. That being said, you can just run the hide operation on the Workbook_open event.

Private Sub Workbook_Open() 
    Application.DisplayFormulaBar = False 
End Sub 

You can turn it on/off depending on the active sheet like so:

Private Sub Workbook_SheetActivate(ByVal Sh As Object)

If Sh.Name = "Sheet1" Then
    Application.DisplayFormulaBar = False
Else
    Application.DisplayFormulaBar = True
End If

End Sub

Answer:

You can accomplish this by using the workbook activate en deactivate events.
Just put Application.DisplayFormulaBar = False into the activate event and Application.DisplayFormulaBar = true in the deactivate event.

Answer:

To avoid all opened Excel sheet formula bar hidden you can go for hiding the formula for a particular excel.

Sub test()

    Sheet1.Unprotect "test"
    Range("A1").FormulaHidden = True ' range which you want to hide formula.

     'your code here
    Sheet1.Protect "test"

End Sub

enter image description here