tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,834
- Office Version
- 365
- 2019
- Platform
- Windows
This code combines two ranges.
It works if the ranges are on the same sheet but fails if they're not.
How can I amend it so it would work?
Thanks
It works if the ranges are on the same sheet but fails if they're not.
Code:
Dim rng1 As Range
Set rng1 = Sheet1.Range("A1:A3")
Dim rng2 As Range
Set rng2 = Sheet2.Range("A1:A3")
Dim rng3 As Range
Set rng3 = Union(rng1, rng2)
Dim rng3element As Range
For Each rng3element In rng3
Debug.Print rng3element.Value
Next rng3element
How can I amend it so it would work?
Thanks