To assign the rows from a named range to a range object so it can be processed.
The named range is created by another earlier function.
I have the following code (an abbreviated extract showing only the relevant code):
Dim rngOrigDataRows As Range
Dim blnInputSheetRowsFiltered as Boolean
' Init. var.
blnInputSheetRowsFiltered = blnWorkbookNameExists(wkbInputModule, INPTMOD_NMDRNG_ROWFILTER_RSLTROWS)
' Get the origonal rowset to work on
If blnInputSheetRowsFiltered Then
Set rngOrigDataRows = .Names(INPTMOD_NMDRNG_ROWFILTER_RSLTROWS).RefersToRange
Set rngOrigDataRows = .Names("InputSheetDataRows").RefersToRange
When the named range 'INPTMOD_NMDRNG_ROWFILTER_
RSLTROWS' does exist the code that assigns it to a range fails with the following error:
1004::Application-defined or object-defined error
The contents of the named range is as follows:
wkbInputModule.Names(INPTMOD_NMDRNG_ROWFILTER_RSLTROWS).RefersTo = "=InputSheet!$35:$37,InputSheet!$41:$48,InputSheet!$52:$71,InputSheet!$73:$84,InputSheet!$87:$94,InputSheet!$97:$126,InputSheet!$129:$149,InputSheet!$153:$160,InputSheet!$164:$183,InputSheet!$185:$196,InputSheet!$199:$228,InputSheet!$231:$250"
There are 12 areas to the range.
If I have only 11 areas then I get no error
Attempts to resolve
I have even tried changing the 12th and final area to point to different rows but it doesn't help.
I have also tried ensuring that the 'InputSheet' worksheet is not protected (just in case) but this had no effect.
I created a new workbook in a new session of Excel and renamed on of the worksheets 'InputSheet' and used the above 'RefersTo' string to create a new range and the error still occurred.
I have never come across this before. To my knowledge ranges can consist of more than 600 areas (no idea why you would want that) but that is far far more than I am using.
My VBA project uses literally hundreds of named ranges over about half-a-dozen workbooks and I have never hit this issue with large row multi-area selections.
What can this be and how can I work around it ?