+ Reply to Thread
Results 1 to 2 of 2

User defined function- count color and count only visible rows

  1. #1
    Registered User
    Join Date
    05-28-2013
    Location
    Columbia, NJ
    MS-Off Ver
    Excel 2003
    Posts
    2

    User defined function- count color and count only visible rows

    I need to create a UDF that will count all cells of a certain color. There are hidden rows in the worksheet. I do not want to count the hidden rows. Can you help me? I created the CountColor function and it is working well.
    I just need to exclude the hidden cells or rows in the count. any help you can provide me is greatly appreciated.

    Thank you
    Darlene


    Function CountCcolor(range_data As Range, criteria As Range) As Long
    Dim datax As Range
    Dim xcolor As Long
    xcolor = criteria.Interior.ColorIndex
    For Each datax In range_data
    If datax.Interior.ColorIndex = xcolor Then
    CountCcolor = CountCcolor + 1
    End If
    Next datax
    End Function

  2. #2
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: User defined function- count color and count only visible rows

    There's a simple solution for this, but first you need to modify your post to comply with the forum rules:

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    I'm interested in starting a career working with VBA, if anyone knows of any opportunities!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Formula to count number of visible rows, and formula to count visible blanks
    By radoncadonc in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-28-2015, 04:19 PM
  2. Replies: 5
    Last Post: 03-06-2015, 07:06 AM
  3. Function - Count User Defined Columns in a Range
    By dspblues in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-16-2014, 09:10 AM
  4. Table Object after filtering - Count visible rows & First visible row
    By limalf in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-13-2013, 07:29 PM
  5. [SOLVED] Count Rows Based On User Input & Trigger Print Of Pages Out Of Count Result
    By wliang in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-09-2012, 02:45 AM
  6. [SOLVED] Function to display a count of visible cells/rows... doesn't
    By Peter Rooney in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-16-2006, 05:30 AM
  7. User defined function to count pay days in current month.
    By dbmathis in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-28-2005, 09:05 PM

Tags for this Thread

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