1

I m try to Union two ranges using Union in VBA by i m getting the below error on line Set rngBothRanges = Union(rngControl, rngFinished). Any ideas?

enter image description here

Code:

Dim arrHeaders As Variant
Dim rngControl As Range
Dim rngFinished As Range
Dim rngBothRanges As Range

Set rngControl = wsControl.Range("A1")
Set rngFinished = wsFinished.Range("A1:H1")

Set rngBothRanges = Union(rngControl, rngFinished)
JvdV
  • 70,606
  • 8
  • 39
  • 70
Error 1004
  • 7,877
  • 3
  • 23
  • 46
  • 8
    You can only Union ranges on the same worksheet – chris neilsen Aug 26 '19 at 09:33
  • What are you trying to achieve if I may ask? – JvdV Aug 26 '19 at 09:56
  • To assign the same formatting to multiple range in different worksheets – Error 1004 Aug 26 '19 at 10:52
  • 1
    Perfect username. One would have to iterate through each range. If you are trying to do this to a large amount of ranges and the ranges are not entirely simple to distinguish, consider storing them in a `collection`, allowing for iteration at the end in a wrapper function. – Oliver Aug 26 '19 at 11:38

0 Answers0