Skip to main content

How to quickly average visible/filtered cells only in Excel?

Author: Sun Last Modified: 2024-09-25

Supposing you have a range of filtered data as below screenshot shown, and you just want to calculate the average of the visible data only. In Excel, if you use the common Average function, it will calculate the average on all the data including visible data and hidden data, but here I introduce some methods which can quickly average visible or filtered cells only in Excel for you.

average filtered cells only

Average visible cells only with User Defined Function

Average visible cells only with Kutools for Excel good idea3


Average visible cells only with User Defined Function

Here, I introduce a User Defined Function for you to average visible cells only.

1. Press Alt + F11 keys to open the Microsoft Visual Basic for Applications window.

2. And click Insert > Module, then paste below VBA code to the new Module window.

VBA: Average visible/filtered cells only.

Function AverVisible(Rg As Range)
'UpdateByKutoolsforExcel20151208
    Dim xCell As Range
    Dim xCount As Integer
    Dim xTtl As Double
    Application.Volatile
    Set Rg = Intersect(Rg.Parent.UsedRange, Rg)
    For Each xCell In Rg
        If xCell.ColumnWidth > 0 _
          And xCell.RowHeight > 0 _
          And Not IsEmpty(xCell) _
          And IsNumeric(xCell.Value) Then
              xTtl = xTtl + xCell.Value
              xCount = xCount + 1
        End If
    Next
    If xCount > 0 Then
        AverVisible = xTtl / xCount
    Else
        AverVisible = 0
    End If
End Function

3. And save the code and close the Module window, and select a blank cell which out put the calculate result, type this formula =AverVisible(B3:B19), and press Enter key to get the correct result. See screenshots:

enter a formulapress enter key to get the result

Tip: In the formula, B3:B19 is the filtered cells you want to calculate the average value, you can change it to your need.


Average visible cells only with Kutools for Excel

With above User Defined Function, you may need to remember the code which is a little inconvenient for you. However, if you have installed Kutools for Excel – a handy tool with 120 useful functions, you can use its AVERAFEVISIBLE function to quickly and easily calculate the average in visible cells only.

Kutools for Excel offers over 300 advanced features to streamline complex tasks, boosting creativity and efficiency. Itegarate with AI capabilities, Kutools automates tasks with precision, making data management effortless. Detailed information of Kutools for Excel...         Free trial...

After free installing Kutools for Excel, please do as below:

1. Select a cell which will put the average result in, and click Kutools > Kutools Functions > Statistical & Math > AVERAGEVISIBLE. See screenshot:

click AVERAGEVISIBLE function of kutools

2. And then select the data range you want to calculate into Reference textbox in the Function Arguments dialog, then you can see the average result has been shown in the dialog. See screenshot:

set cell reference in the dialog box

3. Click OK, and the result is putted in the selected cell.

get the result by kutools

In Kutools’ Functions group, you also can count or sum visible cells only, and sum or count cells based on one color and so on.

Demo: Average Only Visile Cells

 

Relative Articles:

Best Office Productivity Tools

šŸ¤– Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions…
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more
Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!