Sat 07 Jan 2017

Tips & Tricks 153 - Sum only Visible Columns

By |Saturday, January 07th, 2017|Categories: Tips and Tricks, VBA|Tags: , , , , , , , , |3 Comments

You can use SUBTOTAL or AGGREGATE function to sum visible rows but Excel doesn't provide the facility to sum only visible columns. Look below. Columns B and D are hidden. Hence, our function should sum up only A, C, E and F. G2 has the formula =SUM(A2:F2)

If you hide the columns, the sum stays the same whether columns are hidden or visible.


Unfortunately, Excel doesn't provide any native functionality to accomplish this. This will have to be done through a VBA function. We will write a VBA function "SumVisCols" which can be called like =SumVisCols(A2:F2)

(You can give any range not only A2:F2)

1. Make a backup of your workbook.
2. Open your workbook and ALT+F11
3. Locate your Workbook name in Project Explorer Window
4. Right click on your workbook name > Insert > Module
5. Copy paste the Macro code given and change the bold lines as per your requirement
6. Go back to your Workbook and ALT+F8 to display Macro Window
7. Run your Macro from here
8. Delete you Macro if the Macro was needed to be run only once.
9. Otherwise save your file as .xlsm if you intend to reuse Macro again.

' Vijay A Verma (
Function SumVisCols(Rng As Range)
    Dim Cell As Range
    For Each Cell In Rng
        If Cell.EntireColumn.Hidden = False And IsNumeric(Cell) Then
            SumVisCols = SumVisCols + Cell
        End If
    Next Cell
End Function
Sat 28 Nov 2015

Tips & Tricks 120 - Filter by Color Drop Down Menu Greyed Out Problem

By |Saturday, November 28th, 2015|Categories: Tips and Tricks|Tags: , , , , , |6 Comments

Sometimes, you find that though your are having colored cells but Filter by Color is greyed out i.e. it can not be selected.

Following are the possible causes -

1. Your sheets may be grouped. If they are grouped, you will notice word "Group" in the title bar of your Excel workbook.


Another way to check whether the sheets are grouped or not is to right click on any tab name and option "Ungroup Sheets" will appear:


2. There may be blank lines before a color is encountered in your range. Filter doesn't like blank cells. Hence, be watchful.

3. The workbook may be shared. If this is a shared workbooks, the word "Shared" will appear in the title bar of your workbook.


To remove sharing > Review tab > Share Workbook > Uncheck the box in Red zone


4. Also if first colored cell appears after approximately 10000 rows, Excel may not detect the color. To overcome this behavior, put a color in the first cell and now it will enable the Filter by Color. Only thing is that this colored cell will be extra in your filtered list.

5. Edit on 11-Oct-19 - If Filter by color doesn't appear and the worksheet is compatible (>=2007), you play with the column and do some random coloring, or real - at some point it starts showing the menu item.

Credit - Raymond Hilary

Sat 29 Nov 2014

Tips & Tricks 67 - Show the Complete Data in Chart even though Data is Filtered

By |Saturday, November 29th, 2014|Categories: Tips and Tricks|Tags: , , , , |0 Comments

By default, charts in excel show filtered data only.

To show complete data i.e. to ignore filtering -

1. Right click on Chart and click on Select Data.

2. Click on Hidden and Empty Cells at the bottom


3. Select Show data in hidden rows and columns. Now, you will have the result which you want.