ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA to set which columns in Autofilter (https://www.excelbanter.com/excel-programming/291392-vba-set-columns-autofilter.html)

miker1999[_10_]

VBA to set which columns in Autofilter
 
Hello,
I have put code my worksheet_activate to automatically turn on th
Autofilter:

If Not AutoFilterMode Then Cells.AutoFilter

Is there a way to set it to only turn the autofilter on for certai
columns? I need to filter columns A and C:F.

Also, in this code, can I set which row to put the Autofilter on?

Thanks!
Mik

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

VBA to set which columns in Autofilter
 
If Activesheet.AutoFilterMode Then Cells.AutoFilter
Range("A5").CurrentRegion.Resize(,6).AutoFilter _
Field:=3, Criteria1:="F"

I don't think you can skip columns, but I am not sure what would be the
point.

The autofilter filters the entire row, so if a row is hidden, it is hidden
all the way across.

--
Regards,
Tom Ogilvy



miker1999 wrote in message
...
Hello,
I have put code my worksheet_activate to automatically turn on the
Autofilter:

If Not AutoFilterMode Then Cells.AutoFilter

Is there a way to set it to only turn the autofilter on for certain
columns? I need to filter columns A and C:F.

Also, in this code, can I set which row to put the Autofilter on?

Thanks!
Mike


---
Message posted from http://www.ExcelForum.com/




Dave Peterson[_3_]

VBA to set which columns in Autofilter
 
You can hide the autofilter arrow with something like:

ActiveSheet.AutoFilter.Range.Columns(2).AutoFilter field:=2, _
visibledropdown:=False

(Assumes the filter is already in place starting in column A.)

"miker1999 <" wrote:

Hello,
I have put code my worksheet_activate to automatically turn on the
Autofilter:

If Not AutoFilterMode Then Cells.AutoFilter

Is there a way to set it to only turn the autofilter on for certain
columns? I need to filter columns A and C:F.

Also, in this code, can I set which row to put the Autofilter on?

Thanks!
Mike

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson



All times are GMT +1. The time now is 08:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com