Excel

TheSmallman.com

an XL ideas Lab

Dashboards VBA
  • Home
  • Dashboards
    • Tips & Tricks
    • Charts
    • Modelling
    • Infographics
    • VBA
  • Shop Dashboards
    • Power Pivot a User Guide
    • Excel Dashboard Course
    • Advanced Dashboard Course
    • Financial Modelling Course
    • Excel VBA Course
  • Blog
  • About
Menu

Excel Dashboards VBA

Street Address
City, State, Zip
Phone Number
an XL ideas Lab

Your Custom Text Here

Excel Dashboards VBA

  • Home
  • Dashboards
  • Excel Tips
    • Tips & Tricks
    • Charts
    • Modelling
    • Infographics
    • VBA
  • Shop Dashboards
  • PowerPivot
    • Power Pivot a User Guide
  • Courses
    • Excel Dashboard Course
    • Advanced Dashboard Course
    • Financial Modelling Course
    • Excel VBA Course
  • Blog
  • About

Excel What Column is Filtered

April 8, 2016 Marcus Small

Have you ever been using a large Excel file and wondered which cell am I actually filtering here?  Especially if you pick up someone else's file.  There might be more than one column filtered and there may be hundreds of columns.  You tend to go blind after a brief period of looking for that column with a blue arrow on the filter.  Well there is an alternative.  What if every time you filtered the worksheet a colour appeared in the cell(s) you were filtering.  You could see instantly which column was the source of the filter.

The code below will filter any column in light yellow.  It is placed in the worksheet module.

Option Explicit

Private Sub Worksheet_Calculate()
   Dim i As Long

   Rows("1:1").Interior.ColorIndex = xlNone

   If Sheet1.AutoFilterMode Then
      With Sheet1.AutoFilter
         For i = 1 To .Filters.Count
            If .Filters(i).On Then .Range(1, i).Interior.ColorIndex = 19
         Next i
      End With
   End If
End Sub

The VBA code must go in the worksheet which you are running the code from.  So the question to ask yourself is which sheet has the filtered list.

So if the sheet which was being filtered was Sheet1 then paste the code into sheet1 visual basic editor pane.  
If you wanted a different colour, suppose yellow does not go with your workbook colour scheme what you might wish to do is run this vba procedure.  It is how I chose my light yellow colour.

Sub YourColours()
Dim i As Integer
   For i = 1 To 56
      Cells(i, 1).Interior.ColorIndex = i
   Next i
End Sub

If you run this colour code it will place all of the colours from Index from A1 to A56.  There are only 56 colours used by index number (obviously there are limitless colours but with this method you only get 56 colours.  If any of the colours take your fancy from this VBA script then take note of the row number and replace the 19 here.

af.Range.Cells(1, j).Interior.ColorIndex = 19

with your new row number.  Hope this helps.

Tags Column, Filtered, Excel, VBA, colour
← Excel Import Data from Multiple Cells A Dynamic Pareto Chart in Excel →

Featured Posts

Excel Dashboards: Tracking a Crisis

Excel Dashboards: Tracking a Crisis
April 14, 2020

Recent Posts

Populating an Excel Table from a Range of Cells with VBA

Populating an Excel Table from a Range of Cells with VBA June 12, 2025

Fuzzy Distribution with Randbetween

Fuzzy Distribution with Randbetween May 21, 2025

Add Minimum and Maximum for Chart in Cells

Add Minimum and Maximum for Chart in Cells March 12, 2025

Inflation Over Multiple Years in a Single Cell

Inflation Over Multiple Years in a Single Cell January 10, 2025

Hubspot Dashboard

Hubspot Dashboard October 3, 2024

Monthly Dashboard With Supporting Metrics

Monthly Dashboard With Supporting Metrics September 25, 2024

Excel Show Missing Sheet Tabs

Excel Show Missing Sheet Tabs July 29, 2024

Run Macro Overnight Automatically

Run Macro Overnight Automatically June 24, 2024

Split File into Parts and Save to Directory

Split File into Parts and Save to Directory April 20, 2024

Most Popular Author

Most Popular Author December 14, 2023

 

Follow US:

 
 

MarcusSmall@thesmallman.com

 

TheSmallman.com - Making your small systems hum...
© Copyright 2013-2024 theSmallman.com All Rights Reserved.