Selecting Two Sheets to Display Side by Side

M

mcambrose

I often want to display two workbooks side by side. I know how to use the
window command and display all teh open workbooks, but this is a pain because
I often have numerous workbooks open. I then have to downbar all the ones I
don't want to see. Is there a command to display two sheets side by side? I
could probably figure out how to write code to let me select the two sheets I
want. Maybe someone has already done this. Thanks
 
R

Rick Rothstein

Give the following macro a try. First, select two worksheets (select first
worksheet, then Ctrl-Click second worksheet's tab); then, run the macro...
all workbooks other than the active one will be minimized, the active
workbook will be duplicated and tiled, and the two selected sheets will
become the active sheet in each displayed window.

Sub DisplaySameWorksheetSideBySide()
Dim WB As Workbook, FirstSheet As String, SecondSheet As String
With ActiveWorkbook.Windows(1)
If .SelectedSheets.Count <> 2 Then
MsgBox "You must select two sheets in this workbook!"
Exit Sub
End If
FirstSheet = .SelectedSheets(1).Name
SecondSheet = .SelectedSheets(2).Name
End With
For Each WB In Workbooks
If WB.Name <> ActiveWorkbook.Name Then
Windows(WB.Name).WindowState = xlMinimized
Else
Windows(WB.Name).WindowState = xlNormal
End If
Next
ActiveWorkbook.NewWindow
Application.Windows.Arrange xlArrangeStyleVertical
Windows(ThisWorkbook.Name & ":1").Parent.Worksheets(FirstSheet).Select
Windows(ThisWorkbook.Name & ":2").Parent.Worksheets(SecondSheet).Select
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