Dynamic named range for use in data validation list

JackDanIce

Well-known Member
Joined
Feb 3, 2010
Messages
9,922
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have a sheet Settings, A1 contains value "Check_Values", A2:A? are values to be allowed in a drop-down data validation list, where ? is unknown row number.


For a dynamic range, I have named A1 ("Check_Values") and then use formula to name range ("Check_Values_List") for dynamic list: =OFFSET(Check_Values,1,0,COUNTA(Settings!$A:$A)-1,1)


I'd like argument in COUNTA to not refer to sheet name and column address; instead refer to "The column named range Check_Values is in" so there are no direct references to sheet name and column header in the formula.


I.e. =OFFSET(Check_Values,1,0,COUNTA(column Check_Values is in)-1,1)


Can someone suggest correction? Thanks in advance,
Jack
 
Last edited:

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Maybe...

=OFFSET(Check_values,1,,COUNTA(OFFSET(Check_values,,,1000))-1)

Note that 1000 is arbitrary - you can change it.

M.
 
Upvote 0
Awesome @Marceloa Branco list size will unlikely ever exceed 50, should have worked that out myself but much appreciated, thank you :)
 
Upvote 0
Hi Marcelo, sorry if this should be a new thread, I'm curious about a follow-up.

Have named A1 as Sheet_Check, then defined a name, Sheet_Check_Range as =OFFSET(Sheet_Check,1,0,COUNTA(OFFSET(Sheet_Check,1,0,500,1)),5), which currently is range A1:E48 (scope workbook)

This code errors, with method range global failed:
Rich (BB code):
Sub b()
Dim r As Range
Set r = Range("Sheets_Check_Range")
End Sub
Is it because it can't evaluate a dynamic range from the sheet into a VBA object?

Was trying something different from the usual Last Row/Last Column (always 5 in this case) approach to define an unknown row-size range.
 
Last edited:
Upvote 0
Have named A1 as Sheet_Check, then defined a name, Sheet_Check_Range as

It seems you're using wrong name

Set r = Range("Sheets_Check_Range")

Shouldn't it be?
Set r = Range("Sheet_Check_Range")

M.
 
Last edited:
Upvote 0
D'oh, school boy error! Thanks, have working, used named A1: Sht, dynamic area: Sht_Rng and Range("Sht_Rng").Select works, thanks again
 
Upvote 0

Forum statistics

Threads
1,214,525
Messages
6,120,051
Members
448,940
Latest member
mdusw

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