+ Reply to Thread
Results 1 to 3 of 3

Code to Auto-Open New Window that Opens Specific Sheet w/ Windows Arranged Vertically SbS

  1. #1
    Registered User
    Join Date
    11-07-2013
    Location
    Virginia Beach, VA
    MS-Off Ver
    O365
    Posts
    19

    Code to Auto-Open New Window that Opens Specific Sheet w/ Windows Arranged Vertically SbS

    Hello - I want users to:
    1) Open a workbook file and it automatically runs the following:
    2) Opens a New Window to the "Executive & Drill" Sheet. (The Workbook opens to "Dashboard" Sheet and contains a "Legend" Sheet as well)
    3) Apply all sheets' gridline, freeze panes, formula bar, etc. settings throughout the workbook
    4) Arranges the Two Excel Windows vertically (side by side)

    The below already accomplishes most of #2 and #3 but Private Sub Workbook_Open() does not automatically run the maco upon opening. Also, when activated, the new window opens to "Dashboard" not "Executive Drill".

    Any help is appreciated.


    Private Sub Workbook_Open()

    'Create a new window and apply the grid line settings
    'for each sheet.

    Dim ws As Worksheet
    Dim i As Long
    Dim bGrid As Boolean
    Dim bPanes As Boolean
    Dim iSplitRow As Long
    Dim iSplitCol As Long
    Dim iActive As Long

    'Application.ScreenUpdating = False

    'Store the active sheet
    iActive = ActiveSheet.Index

    'Create new window
    ActiveWindow.NewWindow


    'Loop through worksheets of original workbook
    'and apply grid line settings to each sheet.
    For i = 2 To ActiveWorkbook.Windows.Count
    For Each ws In ActiveWorkbook.Worksheets
    Windows(ActiveWorkbook.Name & " - 1").Activate

    ws.Activate
    bGrid = ActiveWindow.DisplayGridlines

    'Get freeze panes
    bPanes = ActiveWindow.FreezePanes
    If bPanes Then
    iSplitRow = ActiveWindow.SplitRow
    iSplitCol = ActiveWindow.SplitColumn
    End If
    Windows(ActiveWorkbook.Name & " - " & i).Activate
    Worksheets(ws.Index).Activate
    ActiveWindow.DisplayGridlines = bGrid
    If bPanes Then
    ActiveWindow.SplitRow = iSplitRow
    ActiveWindow.SplitColumn = iSplitCol
    ActiveWindow.FreezePanes = True
    End If
    Next ws
    'Activate original active sheet
    Worksheets(iActive).Activate
    Next i

    'Activate the original active sheet
    Windows(ActiveWorkbook.Name & " - 1").Activate
    Worksheets(iActive).Activate

    Application.ScreenUpdating = True

    End Sub

  2. #2
    Forum Contributor
    Join Date
    06-20-2021
    Location
    UK
    MS-Off Ver
    2016
    Posts
    126

    Re: Code to Auto-Open New Window that Opens Specific Sheet w/ Windows Arranged Vertically

    Mate would you mind using code tags? It is painful to read it like this. Change macro security settings to trust workbook to use event procedure "workbook_open".

    Perhaps specify worksheet activation like so:

    Please Login or Register  to view this content.
    In your code, I don't see specific reference to sheet name (index or string) that you are asking for.
    Last edited by immigrated4urjob; 09-21-2021 at 03:29 PM.

  3. #3
    Registered User
    Join Date
    11-07-2013
    Location
    Virginia Beach, VA
    MS-Off Ver
    O365
    Posts
    19

    Re: Code to Auto-Open New Window that Opens Specific Sheet w/ Windows Arranged Vertically

    Sorry about that. The thing is, I leveraged that content from code via other sources (not mine). I am a novice. Any help in integrating my sheet names and what you provided into a whole solution would be appreciated.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Open in New Window > Opens in WebBrowser2
    By the5ame in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-17-2016, 06:34 AM
  2. Replies: 3
    Last Post: 07-05-2013, 04:04 AM
  3. VBA code in Windows XP does not work in Window 7
    By handerson0603 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 08-22-2012, 03:51 PM
  4. Replies: 8
    Last Post: 06-19-2012, 06:02 AM
  5. Replies: 0
    Last Post: 05-27-2011, 02:00 PM
  6. Replies: 0
    Last Post: 09-15-2010, 03:57 PM
  7. Replies: 1
    Last Post: 07-01-2005, 11:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1