Formula Bar Hidden

U

ub

Hi
I have written a VBA code to hide formula bar in the Workbook open event.
The code is :
If Application.DisplayFormulaBar = True then
Application.DisplayFormulaBar = False
End if

To bring the formula bar back once I exit out of this workbook, I wrote a
code in workbook before close event and the code is
If Application.DisplayFormulaBar = False then
Application.DisplayFormulaBar = True
End if

I am able to hide the formula bar, but it never brings the formula bar
visible for the application. Every time, after using this sheet, I have to
manualy add the formula bar.

Please advise, how can I correct this problem
 
J

JLGWhiz

Try deleting the If statement and just use:

Application.DisplayFormulaBar = True

No error is generated if the Formula Bar is already displayed.
 
U

ub

Hi
Thanks for the reply

I tried with removing the if statement and it still does not work.

Please advise
 
J

JLGWhiz

After thought. You will also need to save the workbook after you re-instate
the Formula Bar, otherwise it will open in the last saved state.
 
U

ub

I added code
activeworkbook.save
after the Application.DisplayFormulaBar = True statement.
But it still does not work.

Please advise, if I need to change the save statement
 
G

Gord Dibben

Works for me.

Could be done with a few less lines.

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

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.DisplayFormulaBar = True
End Sub


Gord Dibben MS Excel MVP
 
U

ub

Hi Gord

Thanks for the reply.

I have a an Exit button on one of the sheets that closes the workbook.
I put the code [application.DisplayFormulaBar = True ] in the code of this
exit button before the [activeworkbook.save ] and it works now.

Thanks to all
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Prevent user to unhide Formula Bar 2
Hide Excel Ribbon 2007 11
Hide Formula bar while workbook is open 1
Workbook_close 1
Permanently prevent User to see Formula Bar 8
Formula Bar 1
Workbook_Close Q 3
Hide menu bar 1

Top