By "Math Operation", I meant only the theoretical sense. That is, the two
ranges represent sets, and subtract can be a set operation.
How would you handle cases where either range had validation? I know you
can create a validation object, but can you just set a range's validation to
that object? And what there were multiple validations in each range?
I like the speed and simplicity, but the error checking is daunting. I
welcome your input. Thanks,
Matthew Pfluger
"Peter T" wrote:
The 'Tom Ogilvy developed further by Dana DeLouis' approach to subtracting
ranges, and similar to get an inverse range, goes something like this
Sub test()
Dim r1 As Range, r2 As Range, r3 As Range
Set r1 = Range("c5:e9")
Set r2 = Range("e2:f12")
r2.Validation.Add xlValidateInputOnly
r1.Validation.Delete
On Error Resume Next
Set r3 = r2.SpecialCells(xlCellTypeAllValidation)
On Error GoTo 0
r2.Validation.Delete
If Not r3 Is Nothing Then
r3.Select
End If
End Sub
Not included above but required is a check to ensure there is no existing
validation, if there is there are alternative similar methods.
If the purpose is to do a maths calculation (ie subtraction) I'm not sure
producing a subtracted range is an efficient way of going about it. At least
I wouldn't have though so with two single area intersecting ranges as in the
simplified example. Perhaps it depends on what you mean by subtraction.
Regards,
Peter T
"Matthew Pfluger" wrote in
message ...
I have two range objects, and I want to subtract range B from range A.
That
is, I want the opposite of Application.Intersect. This match concept is
illustrated at http://www.mathwords.com/s/set_subtraction.htm
I don't believe there's a single command for this, but can anyone provide
some thoughts? I plan on approaching this using a loop,
Application.Intersect, and Union() commands.
Thanks,
Matthew Pfluger