Problem with two windows for one worksheet

tygrrboi

Well-known Member
Joined
Sep 8, 2015
Messages
1,196
I have two windows open side by side. I want the smaller window to remain on one Sheet - Sheets("Control Panel")
in the other window (the larger one) I want all the stuff to happen.

The problem is, when I do paste special... or make a different sheet visible/invisible, it activates the pasted-in sheet for both windows.

I highlighted the spot in red where my small window suddenly jumps to the wrong sheet... when it shouldnt be moving...

Any idea what I'm doing wrong?


Code:
Sub Set_Teachers()
Dim sT As Worksheet, sL As Worksheet
Set sT = Sheets("Teacher Schedule")
Set sL = Sheets("LayoutA")


Application.ScreenUpdating = False
Application.EnableEvents = False


Windows(MainWindow).Activate


[COLOR=#008000]'Paste Times[/COLOR]
[COLOR=#008000]'Monday[/COLOR]
sT.Range("H3:I35").Copy
[COLOR=#ff0000]sL.Range("B3:AH4").PasteSpecial Paste:=xlPasteValues, operation:=xlNone, SkipBlanks:=False, Transpose:=True[/COLOR]


Sheets("Base Schedule").Activate
Sheets("Teacher Schedule").Visible = False


Application.ScreenUpdating = True
Application.EnableEvents = True


End Sub


Function MainWindow() As Integer
If Windows(1).Width > 0.5 * (Windows(1).Width + Windows(2).Width) Then [COLOR=#008000] 'returns the largest window... the main window[/COLOR]
    MainWindow = 1
Else
    MainWindow = 2
End If
End Function

[TABLE="width: 210"]
<colgroup><col span="2"></colgroup><tbody>[TR]
[TD][/TD]
[TD] [/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Forum statistics

Threads
1,221,478
Messages
6,160,065
Members
451,615
Latest member
soroosh

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