For Each ws In Sheets
If Sheets.Count > 1 Then If Not IsError(Application.Match(ws.Name, t, 0)) _
Then 'ws.Delete ici mettre ton code VBA
Next ws
Function periode(Optional lig As Long = 2)
Application.Volatile 'selon le besoin…
Dim Sh As Worksheet, c As Range
Dim t As Integer, Cpte As Integer
For Each Sh In Sheets
If Sh.Name <> "octobre" And Sh.Name <> "novembre" And Sh.Name <> "décembre" Then
If lig = 0 Then lig = 4
Set c = Sh.Range("C" & lig)
Do While IsDate(Sh.Cells(1, c.Column))
If c = "RF" Or c = "P1" Or c = "" Then
Cpte = Cpte + 1
Else
Cpte = 0
End If
If periode < Cpte Then periode = Cpte
Set c = c(1, 3)
Loop
End If
Next
End Function
Function periode(Optional lig As Long = 2)
Application.Volatile 'selon le besoin…
Dim Sh As Worksheet, c As Range
Dim n As Byte, t As Integer, Cpte As Integer
For Each Sh In Sheets
For n = 0 To 2
If Sh.Name = Array("janvier", "février", "mars") (n) Then
If lig = 0 Then lig = 4
Set c = Sh.Range("C" & lig)
Do While IsDate(Sh.Cells(1, c.Column))
If c = "RF" Or c = "P1" Or c = "" Then
Cpte = Cpte + 1
Else
Cpte = 0
End If
If periode < Cpte Then periode = Cpte
Set c = c(1, 3)
Loop
End If
Next
Next
End Function
n Excel, the Match function searches for a value in an array and returns the relative position of that item. The syntax for the Match function is:Match( value, array, match_type )value is the value to search for in the array.
array is a range of cells that contains the value that you are searching for.
match_type is optional. It the type of match that the function will perform. The possible values are:match_type Explanation 1
(default) The Match function will find the largest value that is less than or equal to value. You should be sure to sort your array in ascending order. If the match_type parameter is omitted, the Match function assumes a match_type of 1.
0 The Match function will find the first value that is equal to value. The array can be sorted in any order. -1 The Match function will find the smallest value that is greater than or equal to value. You should be sure to sort your array in descending order.
If Isempty(c)
Function periode(Optional lig As Long = 2)
Application.Volatile 'selon le besoin…
Dim Sh As Worksheet, c As Range
Dim t As Integer, Cpte As Integer
For Each Sh In Sheets
If Sh.Name <> "novembre" And Sh.Name <> "décembre" And Sh.Name <> "octobre" And Sh.Name <> "janvier" And Sh.Name <> "février" And Sh.Name <> "mars" And Sh.Name <> "avril" And Sh.Name <> "mai" And Sh.Name <> "juin" And Sh.Name <> "juillet" And Sh.Name <> "août" Then
If lig = 0 Then lig = 4
Set c = Sh.Range("C" & lig)
Do While IsDate(Sh.Cells(1, c.Column))
If IsEmpty(c.Value) Or c.Value = "P1" Or c.Value = "RF" Then
Cpte = Cpte + 1
Else
Cpte = 0
End If
If periode < Cpte Then periode = Cpte
Set c = c(1, 3)
Loop
End If
Next
Set c = c(1, 2)
Set c = c(1, 3)
Private Sub ComboBox1_Change()
Label1.Caption = periode(ComboBox1.ListIndex + 4) / 2 & " jours consécutifs "
End Sub
Function periode(Optional lig As Long = 2)
Application.Volatile 'selon le besoin…
Dim Sh As Worksheet, c As Range
Dim t As Integer, Cpte As Integer
For Each Sh In Sheets
If Sh.Name <> "novembre" And Sh.Name <> "décembre" Then
If lig = 0 Then lig = 4
Set c = Sh.Range("C" & lig)
Do While IsDate(Sh.Cells(1, c.Column))
If IsEmpty(c) = True Then
Cpte = Cpte + 1
Else
Cpte = 0
End If
If periode < Cpte Then periode = Cpte
Set c = c(1, 2)
Loop
End If
Next
End Function