+ Reply to Thread
Results 1 to 4 of 4

Counting shaded boxes

Hybrid View

  1. #1
    Registered User
    Join Date
    04-29-2007
    Posts
    2

    Counting shaded boxes

    Hi,

    I was wondering if there was a quick way to count the number of shaded boxes in a column? There are currently no numbers in these boxes and I have about 5-10 columns per worksheet.

    I thought I could make a tally of shaded boxes at the bottom of each column or use a formula to put a number in each shaded box and take a count of those? Alternatively sort the data so the shaded boxes are clumped (currently they are spread out).

    Unfortunately I am not sure if any of these are possible?

    Thanks!

  2. #2
    Forum Expert
    Join Date
    12-24-2004
    Location
    Sweden
    Posts
    1,256

    Count cells with a certain Background Color

    This will Count the number of cells with a certain Background Color.

    I also left a few other option in the code - to switch on/off.
    a) Counts number of colored cells
    b) Sums the content in those cells
    c) Counts the number of cells with the right color and with a content

    Hope it's what you were looking for
    Ola
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by cat85
    Hi,

    I was wondering if there was a quick way to count the number of shaded boxes in a column? There are currently no numbers in these boxes and I have about 5-10 columns per worksheet.

    I thought I could make a tally of shaded boxes at the bottom of each column or use a formula to put a number in each shaded box and take a count of those? Alternatively sort the data so the shaded boxes are clumped (currently they are spread out).

    Unfortunately I am not sure if any of these are possible?

    Thanks!
    Hi,

    a macro something like
    Sub CountInterior()
    Dim c As Range
    Dim iRow As Long, iSubRow As Long
    Dim iTotA As Long, iTotB As Long, iTotC As Long, iTotD As Long, iTotE As Long
    iSubRow = 100
    iTotA = 0: iTotB = 0: iTotC = 0: iTotD = 0: iTotE = 0
    For iRow = 1 To iSubRow
        If Cells(iRow, 1).Interior.ColorIndex > 0 Then iTotA = iTotA + 1
        If Cells(iRow, 2).Interior.ColorIndex > 0 Then iTotB = iTotB + 1
        If Cells(iRow, 3).Interior.ColorIndex > 0 Then iTotC = iTotC + 1
        If Cells(iRow, 4).Interior.ColorIndex > 0 Then iTotD = iTotD + 1
        If Cells(iRow, 5).Interior.ColorIndex > 0 Then iTotE = iTotE + 1
    Next
    Cells(iSubRow, 1).Value = iTotA
    Cells(iSubRow, 2).Value = iTotB
    Cells(iSubRow, 3).Value = iTotC
    Cells(iSubRow, 4).Value = iTotD
    Cells(iSubRow, 5).Value = iTotE
    End Sub
    should do the trick.

    Tools, Macro, Macros, enter the name of the macro, Create and copy the code to the window shown.

    hth
    ---
    added, aaha, beaten to the punch.
    ---
    Si fractum non sit, noli id reficere.

  4. #4
    Registered User
    Join Date
    04-29-2007
    Posts
    2
    Thanks heeps that'll save me hours!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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