Workbook Full View Custom Sheets

kamranyd

Board Regular
Joined
Apr 24, 2018
Messages
152
Office Version
  1. 2021
Platform
  1. Windows
these codes I use for full view sheet, but now I want to add more sheets for full view, how to do it.

VBA Code:
Private Sub Workbook_Activate()
Application.ScreenUpdating = False
If ActiveSheet.Name = "Sheet1" Then

Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)"
Application.DisplayStatusBar = True
ActiveWindow.DisplayWorkbookTabs = True
Application.DisplayFormulaBar = False
ActiveWindow.DisplayHeadings = False
ActiveWindow.DisplayGridlines = False
Application.DisplayScrollBars = False
Application.WindowState = xlMaximized
Else
Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",True)"
End If
Application.ScreenUpdating = True
End Sub
Private Sub Workbook_Deactivate()
Application.ScreenUpdating = False
    Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",True)" 'code to show ribbon.
    Application.ScreenUpdating = True
End Sub

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Application.ScreenUpdating = False
    If Sh.Name = "Sheet1" Then
        Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)" 'code to hide ribbon.
    Else
        Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",True)" 'code to show ribbon.
        Application.ScreenUpdating = True
    End If
End Sub
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Can be achieved with different methods. Just showing one

VBA Code:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Application.ScreenUpdating = False
    If Sh.Name = "Sheet1" or Sh.Name = "Sheet2" or Sh.Name = "Sheet3" Then
 
Upvote 0
thanks this work, if there is another methods can you tell me fast and less code method than this. I want my workbook load and run fast.
 
Last edited by a moderator:
Upvote 0
Hey, I didn't say that! :)

Since we can't use the following characters in sheet names, pick one as delimiter. i.e., *
\
/
?
*
[
]
:
Use instead
VBA Code:
If InStr("Sheet1*Sheet2*Sheet3",Sh.Name)>0 Then

Might have to accomodate for case of letters (capital or lower), using Option Compare Text at the start of module can help. Not near a PC to actually try.

Other's may have better, leaner code.
 
Upvote 0
Hey, I didn't say that! :)

Since we can't use the following characters in sheet names, pick one as delimiter. i.e., *
\
/
?
*
[
]
:
Use instead
VBA Code:
If InStr("Sheet1*Sheet2*Sheet3",Sh.Name)>0 Then

Might have to accomodate for case of letters (capital or lower), using Option Compare Text at the start of module can help. Not near a PC to actually try.

Other's may have better, leaner code.
thanks with this. I don't have to write .Name many time, but what about this line
VBA Code:
If ActiveSheet.Name = "Sheet1" Then
in Private Sub Workbook_Activate() can we use
VBA Code:
If InStr("Sheet1*Sheet2*Sheet3",Sh.Name)>0 Then
here.
 
Upvote 0
Since Sh worksheet object is not defined in that event, replace Sh.Name with ActiveSheet.Name.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,279
Members
452,630
Latest member
OdubiYouth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top