Named ranges

ogo

Board Regular
Joined
Mar 15, 2011
Messages
105
Is there any way to create named ranges with VBA using row& column indexes, say create a named range where start row number us stored in myRow and end row number in endRow and similarly for columns myCol and endCol?
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Try something like this...
Code:
ActiveWorkbook.Names.Add Name:="Test", RefersTo:="=Sheet1!" & Range(Cells(myRow, myCol), Cells(endRow, endCol)).Address
 
Upvote 0
What exactly i need is that i have a column of data(some are repeating) whose start and end row value is stored in variables , now i want to add this data to drop down using named range and also i need to avoid duplicate entries. The length of data exceeds 255 characters so i must use named range..Can anyone help??
 
Upvote 0
Use the Advanced Filter feature to filter your column for just the Unique entries. Copy those unique values from the filtered column to an empty column. The link gives you some very good example code to do that.

Use the new column of unique entries as the reference in your data validation drop down list. Or redefine your named range to the column of unique entries.
 
Upvote 0

Forum statistics

Threads
1,224,504
Messages
6,179,142
Members
452,892
Latest member
JUSTOUTOFMYREACH

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