View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Qazi Ahmad Qazi Ahmad is offline
external usenet poster
 
Posts: 32
Default How to get Total of Coloured Cell in a Colum and Worksheet

Dear
I want to clear my Question that in Selected Cell Range I have some colored
cell not all selected raged full on colored cells. I use different colors in
selected range. Now I want to count how many colored cell in range and what
the total to different colors which I use. (Below mentioned VB Module, where
it display Result ??)
Ahmad


"steve_doc" wrote:

Hi

A couple of questions spring to mind - Are all the coloured cells the same
colour?

You could use a VBA routine to count the number of coloured cells.
Below is the code I used in a standard VBA module.This assumes that there
are no blank cells in the range.

Sub countColouredCells()
Dim wb As Workbook
Dim ws As Worksheet
Dim rg As Range
Dim i As Integer

Set wb = ThisWorkbook
Set ws = wb.Worksheets(1)
Set rg = ws.Range("B1")
i = 0

Do Until IsEmpty(rg)
If rg.Interior.ColorIndex = 3 Then
i = i + 1
Set rg = rg.Offset(1, 0)
Else
Set rg = rg.Offset(1, 0)
End If
Loop
Debug.Print i
End Sub


"Qazi Ahmad" wrote:

How I get total of highlighted/Coloured Cell in a Colum .
How to get total of highlighted/coloured Cell in a Worksheet.