Highlight autofiltered column headers

mfleuette1

New Member
Joined
Jul 1, 2013
Messages
4
Good evening - I searched this forum and did not find the answer to my question and was wondering if someone could provide help?

I am querying a SQL Server table to return query results into Excel 2010; it is returning 55+ columns.

Because there are more than 20 columns being returned, I'd like to highlight any autofiltered columns in magenta (colorindex = 7). I already have a macro to turn off all autofiltered columns...

I am pretty certain this will require listobjects(1) but so far have been unable to figure out:
a) how to determine if a particular column has an autofilter applied, and
b) how to set the colorindex for the column header

Solution outline -

Find columnheader row
i = 0
If any autofilter on
loop
i = i+1
if column(i) has autofilter on
set column header cell color to 7
else
set column header cell color to 0
end if
end loop
end if


It may be that you cannot change the color on a query's header cell (I don't know), in which case, the cell above the column header cell should have its color changed.

I can see the autofilter criteria by mousing over the autofilter arrow for a filtered column, so displaying the autofilter criteria is a "nice to have" at this point, not a "necessary". (Does anyone know how to put the filter criteria displayed during mouse-over into a cell?)

Does anyone on the board have familiar with how to check autofilters for data returned by a query?

Thank you in advance for any responses -
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Good evening - I searched this forum and did not find the answer to my question and was wondering if someone could provide help?

I am querying a SQL Server table to return query results into Excel 2010; it is returning 55+ columns.

Because there are more than 20 columns being returned, I'd like to highlight any autofiltered columns in magenta (colorindex = 7). I already have a macro to turn off all autofiltered columns...

I am pretty certain this will require listobjects(1) but so far have been unable to figure out:
a) how to determine if a particular column has an autofilter applied, and
b) how to set the colorindex for the column header

Solution outline -

Find columnheader row
i = 0
If any autofilter on
loop
i = i+1
if column(i) has autofilter on
set column header cell color to 7
else
set column header cell color to 0
end if
end loop
end if


It may be that you cannot change the color on a query's header cell (I don't know), in which case, the cell above the column header cell should have its color changed.

I can see the autofilter criteria by mousing over the autofilter arrow for a filtered column, so displaying the autofilter criteria is a "nice to have" at this point, not a "necessary". (Does anyone know how to put the filter criteria displayed during mouse-over into a cell?)

Does anyone on the board have familiar with how to check autofilters for data returned by a query?

Thank you in advance for any responses -

Does anyone know how to check autofilter status in Excel 2010? Thanks!
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,490
Members
448,967
Latest member
visheshkotha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top