Results 1 to 2 of 2

#VALUE error when counting cells

Threaded View

  1. #1
    Registered User
    Join Date
    02-27-2019
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    70

    #VALUE error when counting cells

    Hello,

    I use the code below to count cells with a certain fill color and when they are empty.
    When i try this in an empty sheet it works perfectly but when i implement this into a big sheet where the sollution is for i get a #VALUE error.
    There is no error in the range so that cannot be the problem. I know it is hard to find a sollution when the real workbook isn't provided but i realy can't upload that.
    Does anyone know what can trigger this error? I added a example sheet if the cell count sollution isn't clear to anyone.

    TX!

    Public Function CountCells(RNG As Range) As Double
        Application.Volatile
    For Each CL In RNG
        If IsEmpty(CL) = True Then
            With CL.Interior
                If .Pattern = xlSolid And .Color = RGB(146, 205, 220) Then
                    CountCells = CountCells + 1
                End If
            End With
        End If
    Next CL
    
    
    End Function
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Overflow error on worksheet_selectionchange when counting selected cells
    By Spritz in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-04-2021, 01:05 PM
  2. Replies: 3
    Last Post: 08-30-2018, 11:13 PM
  3. [SOLVED] Error counting cells by colour
    By Tony0731 in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 07-27-2018, 08:47 AM
  4. [SOLVED] COUNTIFS - Counting in order in one column, Counting only specific cells In another
    By kslattery in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-25-2017, 01:17 PM
  5. [SOLVED] Counting number of non-blank cells in column......but getting run time error in vba
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-30-2012, 10:54 AM
  6. Replies: 3
    Last Post: 03-01-2012, 06:17 AM
  7. counting cells with data without counting duplicates
    By labettis in forum Excel General
    Replies: 2
    Last Post: 11-05-2007, 12:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1