Ce devrait être:
resultat = Application.Union - Application.Intersect
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionSub test() Exclude([B3:D12], [A10:C19]).Select End Sub Function Exclude(ByRef voA As Range, ByRef voB As Range) As Range Dim oI As Range Dim oU As Range If Not (Nothing Is voA Or Nothing Is voB) Then Set oI = Intersect(voA, voB) Set oU = Union(voA, voB) If Nothing Is oI Then Set Exclude = oU Else With oU .Validation.Delete .Validation.Add xlValidateInputOnly, xlValidAlertStop oI.Validation.Delete Set Exclude = .SpecialCells(xlCellTypeAllValidation) End With End If End If End Function
Private Sub CommandButton3_Click() exclus([B3:D12], [A10:C19]).Select End Sub Private Function exclus(r1 As Range, r2 As Range) As Range Dim letout As Range, partage As Range, tremplin As Variant Set letout = Application.Union(r1, r2) Set partage = Application.Intersect(r1, r2) r1t = r1.Value r2t = r2.Value letout.Value = "" partage.Value = "on s'en fout" Set exclus = letout.SpecialCells(xlCellTypeBlanks) r1.Value = r1t r2.Value = r2t Set letout Nothing: Set partage Nothing End Function