Rapport de message :*
 

Re: Aide sur code

Titre du sujet : Re: Aide sur code
par kelly le 09/05/2009 18:13:10

Bonjour,
Voici le code :


Private Sub Worksheet_Change(ByVal Target As Range)
Dim C As Byte
Dim KO As Boolean
    If Target(1).Value = "" Then Exit Sub
    If Not Application.Intersect(Target, Cells.SpecialCells(xlCellTypeAllValidation)) Is Nothing Then
        With Target
            If .Validation.Formula1 = "=Matériel" Then
                Select Case Application.CountIf(.EntireRow, .Value)
                Case Is > 2
                    KO = True
                Case Is > 1
                    For C = 3 To 13
                        If Cells(.Row, C).Value = .Value And C <> .Column Then
                            KO = Cells(2, C).Value = Cells(2, .Column).Value
                            Exit For
                        End If
                    Next C
                End Select
            End If
        End With
    End If
    If KO Then
        MsgBox "Ce matériel est déjà réservé sur cette période !"
        Application.Undo
    End If
End Sub


Avec toutes mes excuses.
Merci