Display formula in all worksheets

S

slc

Need help...

My workbook has multiple worksheets. I am trying to create a macro
that will display the formula in all the worksheets with 1-step. The
following macro don't seems to work. Thanks for your help.


Sub ShowFormula()
'
' Display formula instead of value in all worksheets
'
Dim Sh As Worksheet
'
For Each Sh In ActiveWorkbook.Worksheets
ActiveWindow.DisplayFormulas = True
Next
End Sub
 
M

mangesh_yadav

This worked for me.

Sub MyDisplayFormula()

ActiveWindow.DisplayFormulas = True

End Sub

Manges
 
N

Norman Jones

Hi SLC,

Your sub fails because whilst you cycle through the worksheets, the active
window remains unchanged.

Try:

'========================>>
Public Sub ShowFormula()

'\\ Display formula instead of value in all worksheets

Dim SH As Worksheet
Dim SHcurrent As Worksheet

Set SHcurrent = ActiveSheet

Application.ScreenUpdating = False

For Each SH In ActiveWorkbook.Worksheets
SH.Activate
ActiveWindow.DisplayFormulas = True
Next

SHcurrent.Activate

Application.ScreenUpdating = True

End Sub
'<<========================

And, anticipating your next question...:


'========================>>
Public Sub HideFormulas()

'\\ Restore value display in all worksheets

Dim SH As Worksheet
Dim SHcurrent As Worksheet

Set SHcurrent = ActiveSheet

Application.ScreenUpdating = False

For Each SH In ActiveWorkbook.Worksheets
SH.Activate
ActiveWindow.DisplayFormulas = False
Next

SHcurrent.Activate

Application.ScreenUpdating = True

End Sub

'<<========================
 

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

Top