Can't create AutoFiltered Excel worksheet using VB.NET

Giganews Newsgroups
Subject: Can't create AutoFiltered Excel worksheet using VB.NET
Posted by:  John Brock (jbro…@panix.com)
Date: Mon, 5 Jun 2006

I am trying to create a workbook where one of the worksheets contains
an AutoFiltered table.  It looks like it should be simple -- what
I am doing is this:

        rng = ws.Range("MyTableRange")
        rng.AutoFilter()

Unfortunately I get an exception on the second statement, with the
unhelpful message:

    AutoFilter method of Range class failed

The range is rectangular, and contains a legitimate table, with
column headers in the first row and data in most of the cells.  If
I create the workbook without calling the AutoFilter statement,
then manually go to the range in question and set AutoFilter from
the Excel Data menu, it works as expected.  The worksheet is intended
to be protected, but protection has not yet been set at the point
where I try to set AutoFilter.

I Googled for this, and found two other people complaining of the
same thing, with no answers.  I suspect (and hope!) this means that
there is an answer -- otherwise there would be many more queries.

Any help would be gratefully appreciated!

--
John Brock
jbro…@panix.com

Replies