AutoFilter selected row not 'retained' across user unselect/select

Y

YoDave

Sorry if this is the wrong place for this, first post ever!

I'm building a tool to create a set of workbooks.
Our 'header' consists of 6 rows, mostly blank,with the column names on row
4, and the column names duplicated on row 6. Data starts in row 7.

When testing, I was able to set and file the AutoFilter programmatically on
Row 6. When I opened the books, Row 6 had the dropdowns.

When (me the user) clicked off the autofilter and clicked it back on, it set
the autofilter row to row 4?

Is there something programmatically I need to set to retain row 6 as the
AutoFilter row?

Thanks,
 
D

Dave Peterson

Are you selecting the exact range you want filtered or letting excel guess.

I bet you're not selecting the exact range, then applying the filter.
 
Y

YoDave

ty for response.

Range is set. I'm using

wb.open()
....
Excel.Range afRange = get_Range("A6", "E6");
afRange.AutoFilter(1, Type.Missing,
Excel.XlAutoFilterOperator.xlAnd, Type.Missing, true);
....
wb.SaveAs(newname);

So that I can reuse the template and set specifics for different workbooks.
This is working ok.
In my set of saved workbooks, when I open one, Row 6 is indeed set as the
autofilter row on each sheet. However, when I click autofilter off, then
click it back on, it loses track of row 6, and is setting row 4!

I guess my question is, ms knew what row autofilter was set on when the
workbook was opened by the user, but when the user starts playing around, the
row or range that was set is lost?
 
D

Dave Peterson

I'm not sure what click autofilter on and off mean. But if I'm doing things
manually, I'd select the range first.

If I'm doing it in code (VBA), I'd remove the existing filter arrows and reapply
them to the range I wanted.

With Worksheets("SomeSheetNameHere")
.autofiltermode = false
.range("a6:E6").autofilter
End with

I don't speak that stuff you're speaking <vbg>.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top