Re : Affichage intempestif d'un userform (ou plutôt "non désaffichage" malgré unload
Hello,
Là sans fichier joint, on ne pourra te répondre !
T'as peut-être un "UserForm1.Show" qui traine quelque part...
_______________________________________________________________
Salut Hulk,
voici mon code : tu verras que dès la routine suivant l'affichage du userform, je mets l'instruction unload
Je travaille avec des enchainements de call ... (voir à la fin)
Merci pour ton aide
_______________________________________________________________________________________
Option Explicit
Public Kombination As Variant
Sub Periode_Anfrage()
Sheets("Paramètres").Select
Range("G100").Select
UserForm_Wahl_Tag_Monat_JAhr.Show
End Sub
Sub Arbeitsmappe_hinzufuegen()
Unload UserForm_Wahl_Tag_Monat_JAhr ' dès cette ligne, je désactive le userform !!! mais en vain !!!
Application.ScreenUpdating = False
Dim i As Byte
Sheets("Paramètres").Select
Kombination = Range("G105").Value & Range("H105").Value
For i = 1 To Sheets.Count
If Kombination = Sheets(i).Name Then
Exit Sub
End If
Next i
Sheets.Add after:=Sheets(Worksheets.Count)
Sheets(Worksheets.Count).Name = Kombination
With ActiveWorkbook.Sheets(Kombination).Tab
.Color = 49407
.TintAndShade = 0
End With
End Sub
Sub Konvertieren()
Dim Wb As Workbook
For Each Wb In Workbooks
If Wb.Name = "Chiffres_ELIT.xlsx" Then
Windows("Chiffres_ELIT.xlsx").Close
End If
Next Wb
ChDir _
"C:\Documents and Settings\Propriétaire\Mes documents\DATA\Perso\Informatique\Statistiques"
Workbooks.OpenText Filename:= _
"C:\Documents and Settings\Propriétaire\Mes documents\DATA\Perso\Informatique\Statistiques\Chiffres_ELIT" _
, Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier _
:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=True _
, Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1) _
, Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), _
Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1), Array(14, 1), Array(15 _
, 1), Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1), Array(20, 1), Array(21, 1), _
Array(22, 1), Array(23, 1)), TrailingMinusNumbers:=True
Range("W1").Select
ActiveCell.FormulaR1C1 = "Mois"
Range("X1").Select
ActiveCell.FormulaR1C1 = "Année"
Range("Y1").Select
ActiveCell.FormulaR1C1 = "Période"
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\Propriétaire\Mes documents\DATA\Perso\Informatique\Statistiques\Chiffres_ELIT.xlsx" _
, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
Dim LetzteZeile As Long
LetzteZeile = Sheets("Chiffres_ELIT").Range("A" & Rows.Count).End(xlUp).Row
Dim i As Long
Dim Month As Variant
Dim Year As Variant
Dim Periode As Variant
Workbooks("Stat_semaine_light.xlsm").Activate
Sheets("Paramètres").Select
Month = Range("G105").Value
Year = Range("H105").Value
Periode = "du 1er au " & Range("F105").Value
Workbooks("chiffres_ELIT.xlsx").Worksheets("Chiffres_ELIT").Activate
With Sheets("Chiffres_ELIT")
For i = 2 To LetzteZeile
Cells(i, 23) = Month
Cells(i, 24) = Year
Cells(i, 25) = Periode
Next i
End With
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\Propriétaire\Mes documents\DATA\Perso\Informatique\Statistiques\Chiffres_ELIT.xlsx" _
, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
Application.DisplayAlerts = True
End Sub
Sub Transferieren()
Windows("Chiffres_ELIT.xlsx").Activate
Cells.Select
Selection.Copy
Windows("Stat_semaine_light.xlsm").Activate
Worksheets(Kombination).Activate
Range("a1").Activate
ActiveSheet.Paste
Application.CutCopyMode = False
Windows("Chiffres_ELIT.xlsx").Close
End Sub
Sub Sortieren_mit_dynamischer_Zone()
Sheets("BASE").Activate
Dim numlign As Long
numlign = ActiveSheet.UsedRange.Rows.Count
Range("A2:Y" & numlign).Name = "Flaeche_zum_Sortieren"
Application.Goto reference:="Flaeche_zum_Sortieren"
ActiveWorkbook.Worksheets("BASE").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("BASE").Sort.SortFields.Add Key:=Range("X2:X" & numlign) _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("BASE").Sort.SortFields.Add Key:=Range("W2:W" & numlign) _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("BASE").Sort
.SetRange Range("A1:Y" & numlign)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Sub Zeilen_entfernen_und_Daten_einfuegen()
Dim LetzteZeile As Long
Dim i As Long
Dim Month As String
Dim Year As Long
Sheets("Paramètres").Activate
Month = Range("G105").Value
Year = Range("H105").Value
Sheets("BASE").Activate
For i = ActiveSheet.UsedRange.Rows.Count To 2 Step -1
If Cells(i, 23) = Month And Cells(i, 24) = Year Then Rows(i).Delete
Next i
Sheets("Paramètres").Activate
Dim Concaténation As String
Concaténation = Range("G105").Value & Range("H105").Value
Worksheets(Concaténation).Activate
Range("Y2").Select
Dim ZeilenNummer As Long
ZeilenNummer = ActiveSheet.UsedRange.Rows.Count
Range("A2:Y" & ZeilenNummer).Name = "Selektierte_Flaeche"
Application.Goto reference:="Selektierte_Flaeche"
Selection.Copy
Sheets("BASE").Select
Rows("2:2").Select
Selection.Insert Shift:=xlDown
End Sub
Sub Stats()
Call Periode_Anfrage
Call Arbeitsmappe_hinzufuegen
Call Konvertieren
Call Transferieren
Call Sortieren_mit_dynamischer_Zone
Call Zeilen_entfernen_und_Daten_einfuegen
Call Purge
End Sub
Sub Purge()
Dim i As Long
Dim client_fictif As Range
Dim Cellule As Range
Dim ReponseMsgBox As Byte
Dim Base As Range
Set Base = Sheets("Base").Range("E2:E" & Sheets("Base").Range("E" & Rows.Count).End(xlUp).Row)
Set client_fictif = Sheets("Paramètres").Range("F2:F" & Sheets("Paramètres").Range("F" & Rows.Count).End(xlUp).Row)
For Each Cellule In client_fictif
If Application.WorksheetFunction.CountIf(Base, Cellule.Value) > 0 Then
ReponseMsgBox = MsgBox("voulez-vous vraiment supprimer " & Cellule.Value & " ?", vbOKCancel, "Question")
If ReponseMsgBox = vbOK Then
With Sheets("Base")
For i = .UsedRange.Rows.Count To 2 Step -1
If .Cells(i, 5) = Cellule.Value Then .Rows(i).Delete
Next i
End With
End If
End If
Next
End Sub