Need a functioning range name.

Ribbs

New Member
Joined
Aug 7, 2020
Messages
1
Office Version
  1. 365
Platform
  1. Windows
I’m trying to name a range of every other cell in a column. I don’t want to merely select the cells and name the selection. There are fifty cells in the range, and it will likely change, so I need it to be dynamic.

It will be used in a macro. So far I have tried these formulas on a smaller, experimental range:

=IF(ISODD(ROW($E$7: $E$16)), $E$7: $E$16,"")

=SORT(INDEX($E$7: $E$16,SEQUENCE(COUNTA($E$7: $E$16)/2,1,1,2),SEQUENCE(1,3)),2)

=INDEX($E$7: $E$16,SEQUENCE(COUNTA($E$7: $E$100)/2,1,1,2),1)

=IF(ROW($E$7: $E$16)=SEQUENCE(10,1,2,2), $E$7: $E$16,"")

=FILTER($E$7: $E$16,ROW($E$7: $E$16)=SEQUENCE(10,1,2,2))

=FILTER($E$7: $E$16,ROW($E$7: $E$16)=SEQUENCE(5,1,2,2))

=INDEX($E$7: $E$16,2+SEQUENCE(5,1,0,2)*1)

=INDEX($E$7: $E$16,MOD(ROW($E$7: $E$16),2),1)

=INDEX($E$7: $E$16,MOD(ROW($E$7: $E$16),2)=1,1)

The first formula shows the most promise. The syntax is clear and intuitive, and it works beautifully as a worksheet formula. But, like most of the others, when I create a named range with it and then try to select the range with a macro, I get the message “Error ‘1004’ Method Range of Object Global Failed”.

The 100 cells from which the fifty are selected is named with this dynamic formula:

=OFFSET(E$7,0,1,1,(MATCH(2,1/($E$7:OFFSET($E$7,0,200,1,1)<>"")))-1)

So:

1) Can anyone suggest a formula that will work, and

2) for future reference, how can a formula that works so well as a worksheet formula fail as the definition of a range name?

Thank you for your time and the benefit of your expertise.
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Your named range is creating an array, not a range.

Might be better to create a proper range of all rows (odds and evens) then loop through then and create a union from the odd rows.
 
Upvote 0

Forum statistics

Threads
1,215,480
Messages
6,125,049
Members
449,206
Latest member
Healthydogs

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top