1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
Sub test()
Dim Plage1 As Range, Plage2 As Range
Set Plage1 = Range("D5, D9, D11, D15, D18, E6, E8, E11, E13, E18")
Set Plage2 = Minus(Plage1, ActiveCell)
End Sub
Function Minus(ByVal A As Range, ByVal B As Range) As Range 'Plage A moins Plage B
Dim plage As Range, cell As Range
Set Minus = Nothing
For Each plage In A.Areas
For Each cell In plage
If Intersect(cell, B) Is Nothing Then
If Minus Is Nothing Then Set Minus = cell _
Else Set Minus = Union(Minus, cell)
End If
Next cell
Next plage
End Function |
Partager