Forum Discussion

ajl_ahmed's avatar
ajl_ahmed
Iron Contributor
Jul 09, 2022

creating three buttons to display page 1, page 2 and all pages of sheet 1 (excel file)

I have a worksheet in an excel file (Office 365) consisting of two pages in (sheet 1). I want to create three buttons as described below:
button 1: to display page 1 of sheet 1 only.
button 2: to display page 2 of sheet 1 only.
button 3: to display all (Pages 1 & 2) of sheet 1.
 
I do not know how can I do it. Hope to help me to do this issue. 
 
Regards
  • NikolinoDE's avatar
    NikolinoDE
    Gold Contributor

    ajl_ahmed 

    So you could generate page previews for each individual sheet...insert code in a VBA button.

     

     

    Option Explicit
    
    Sub Print_Preview()
    With ActiveSheet.PageSetup
    ActiveWindow.SelectedSheets.PrintPreview
    'ActiveSheet.PageSetup.PrintArea = "A1:AH60" 'only if you like to see only specific area
    
    End With
    
    End Sub

     

     

Resources