How to set and use an empty range in VBA?

I would like to use an empty range as follows:

Set NewRange = Union(EmptyRange, SomeRange)

I tried to set EmptyRangeas an empty range using Nothing, Emptyand Null, but a "runtime error" 5 "Invalid call or procedure argument" occurs, does it seem like I should use an instruction Ifor is there another keyword that does the job?

I can use:

If EmptyRange Is Nothing Then
   Set NewRange = SomeRange
Else
   Set NewRange = Union(EmptyRange, SomeRange)
End If

instead of building:

Set NewRange = Union(EmptyRange, SomeRange)
+4
source share
1 answer

Union() . -. SomeRange Empty, :

Set NewRange = SomeRange

Union() , Union() DEFINED.

http://msdn.microsoft.com/en-us/library/office/aa213609%28v=office.11%29.aspx

+2

Source: https://habr.com/ru/post/1568218/


All Articles