Private Sub CommandButton3_Click()
exclus([B3:D12], [A10:C19]).Select
MsgBox exclus([B3:D12], [A10:C19]).Address
End Sub
Private Function exclus(r1 As Range, r2 As Range) As Range
' code libre d'utilisation et/ou diffusion. Seule obligation : y ajouter la mention suivante :
' ******code provenant du forum VBFrance de Codes-Sources - Auteur : ucfoutu*************
Dim letout As Range, partage As Range
Dim r1valeur As Variant, r1formula As Variant, r2valeur As Variant, r2formula As Variant
Set letout = Application.Union(r1, r2)
Set partage = Application.Intersect(r1, r2)
If Not Nothing Is partage Then
r1valeur = r1.Value: r1formula = r1.Formula
r2valeur = r2.Value: r2formula = r2.Formula
letout.Value = vbNullString
partage.Value = "non vide"
Set exclus = letout.SpecialCells(xlCellTypeBlanks)
r1.Value = r1valeur: r1.Formula = r1formula
r2.Value = r2valeur: r2.Formula = r2formula
Else
Set exclus = letout
End If
Set letout = Nothing
Set partage = Nothing
End Function