Free Support Forum -

Finding named ranges

I need to be able to use the ExportDataTableAsString method for a named range. The range has a known name ("Upload") but it may be on any worksheet in the workbook. I see two ways to do this, but I'm having problems with both. If I could get one of these working, that would be great.

1) I can use Worksheets.GetRangeByName("Upload") to get the Range, but I don't see any way to get the worksheet from the Range object (I need the Worksheet object for the call to ExportDataTableAsString.) Is there any way to do this?


2) According to the documentation, I should be able to iterate through the worksheets and then through each worksheet's Cells.Ranges collection and test the Range.Name value. When I find one named "Upload" I know the Worksheet and the Range. However, I have two problems with this:

a) The Ranges collection always appear empty, even though there are named ranges on the worksheets.

b) When I've managed to actually get Range objects (using other functions), the Name property is always Nothing.

Might I be doing something wrong?

Thanks you, David

Hi David,

1)I will add a property to Range object to return the worksheet object. It will be available in the next release.

2)Ranges collection returns a collection of Range set at run time. So it will not return named range in your designer spreadsheet.

Thanks Laurence. Do you know when that will be available?

Just in a few days. I will release a new hotfix including this feature in this week or at the start of next week.

Please download the latest hotfix and have a try.

Works perfectly. Thank you.