Bonjour à toutes et tous,
Afin d'aider Capucin, qui travaille avec Excel 2003, pouvez-vous vérifier la procédure dans le fichier joint?
Avec pour la partie surlignée les valeurs de 1 et 2 pour wns().
La question est : Peux-t'on sélectionner les cellules A1 (ou autres) des feuilles en fin de procédure?
Testé chez moi en xls et xlsm et ça fonctionne
Merci par avance
Cdlt.
Option Explicit
Option Private Module
Public Sub TwoWindows()
Dim cnt As Long, i As Long
Dim wn As Window
Dim wns(1 To 2) As Window
Dim col As Collection
Application.ScreenUpdating = False
For Each wn In ActiveWorkbook.Windows
cnt = cnt + 1
If cnt > 2 Then
wn.Close
Else
Set wns(cnt) = wn
End If
Next
If cnt = 1 Then
Set wns(2) = ActiveWindow.NewWindow
End If
Set col = New Collection
For Each wn In Application.Windows
If wn.Visible Then
If wn.Parent Is ActiveWorkbook Then
wn.WindowState = xlNormal
Else
col.Add wn
wn.Visible = False
End If
End If
Next
wns(2).Activate
Worksheets("Feuil2").Activate
wns(1).Activate
Worksheets("Feuil1").Activate
Application.Windows.Arrange ArrangeStyle:=xlVertical
For i = col.Count To 1 Step -1
col(i).Visible = True
Next
For i = 2 To 1 Step -1
wns(i).Activate
Next
wns(1).Activate ' activate preferred window
Range("A1").Select
End Sub