PDA

View Full Version : Solved: named ranges



philfer
12-15-2008, 06:28 AM
Hello,

If I have a named range say of cells A1 to AD1 which can grow and shrink i.e. users can add columns anywhere in the middle, is there a way of finding the last column in the current range (i.e. given its current size).

I'd like to be able to find the column index i.e that it is column 28 for example

Cheers
Phil

CreganTur
12-15-2008, 06:35 AM
Take a look at this www.vbaexpress.com/forum/showpost.php?p=156718 from MD, which shows how to create a dynamic named range. Now, his example will find the last used Row, not column, but you will be able to adjust it for Columns.

philfer
12-15-2008, 06:38 AM
Thanks for that but I need to do it programmatically i.e. each time I run some code in the workbook I need to get the last column of a neamed range within VBA and assign it to a variable where I will use it elsewhere in the same Sub

Thanks
Phil

Bob Phillips
12-15-2008, 06:53 AM
Range("myRange")(Range("myRange").Count).column