1

I have some Dynamic named Ranges in my sheet.Ive made them dynamic using the following formula:

=$A$1:rowend($A$1)

Where row end is a custom function which return the last cell before an empty cell is reached in row "A"

The named range is named as follows : "iec_air" There is also another named range : "iec_ground"

Now the problem is when i apply datavalidation on a cell and choose list referring to "iec_air" directly it works but when try to achieve the same thing using indirect("iec_"&"air") it doesnt work

When my named ranges were static it was working,not its not.Any idea how to fix it?

4

1 回答 1

1

Do you know how to use VBA? One of the things you can do is create an event in a sheet module and adapt the size of the named range dynamically based on the blank cell.

Example

Sub setRangeDynamically()

dim oRange     as range

'Set range from cell(1,1) until the first blank cell downwards
set oRange = thisworkbook.sheets("blabla").range(cells(1,1),cells(1,1).end(xldown))
thisworkbook.Names.Add Name:="MyRange", RefersTo:=oRange 
end sub

To create the data validation:

With thisworkbook.sheets("BlaBla").range("B2").Validation 
    .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _ 
    xlBetween, Formula1:="=MyRange" 
End With
于 2012-05-08T13:17:37.727 回答