I am attempting to merge several worksheets into one range. I have code as follows:
However, when the Union procedure attempts to execute, I get the following error:
Run-time error '1004':
Method 'Union' of object '_Global' failed
Any help would be greatly appreciated.
Code:
' rHistory is defined as a Range above and contains a Range
Dim rTemp As Range
For i = 2 To nNumHistory
sRangeName = "'Sheet" & i & "'!A1:F100" ' modified example
Set rTemp = Range(sRangeName)
Set rHistory = Union(rHistory, rTemp)
Next i
Run-time error '1004':
Method 'Union' of object '_Global' failed
Any help would be greatly appreciated.