Range fails when its split on different cells

Aug 31, 2011 at 10:24 AM

Let's see if i can explain this well.

At Excel, I got on my worksheet a Named Range that is like this:

Name: SessoesPresenca

Refers To: =Sumários!$B$12;Sumários!$B$19;Sumários!$B$26;Sumários!$B$33;Sumários!$B$40

When i do:

var sessoes = wb.Worksheet("Sumários").Range("SessoesPresenca");

It gives me the error at that line:

Sequence contains no matching element

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Sequence contains no matching element

Thanks for the help.

Coordinator
Aug 31, 2011 at 3:27 PM

That's because SessoesPresenca contains multiple ranges. Use:

var sessoes = wb.Worksheet("Sumários").Ranges("SessoesPresenca");
Aug 31, 2011 at 3:48 PM

Oh! that makes sense :)

Thanks. will try it later.

Aug 31, 2011 at 4:03 PM

I Just try it and doesn't work.

Coordinator
Aug 31, 2011 at 4:05 PM

I'll fix it then...

Coordinator
Sep 1, 2011 at 3:04 AM
Edited Sep 1, 2011 at 3:06 AM

Pick up the latest check-in. Be aware that you need to separate the ranges with commas instead of semicolons, otherwise Excel interprets it as a string.

Sep 1, 2011 at 8:55 AM

Thanks a lot for the great work.