Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
First I want to count the number of cells in a range that have text in them.
Then I want to count how many of these cells have the back ground color 36 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Oldjay
This will achieve what you want for a continuous range, Column A in this example. Change the variables to suit. Take care Marcus Option Explicit Sub MyCount() Dim lw As Integer Dim counter As Integer Dim MyConstant As Integer Dim i As Integer lw = Range("A" & Rows.Count).End(xlUp).Row counter = 0 MyConstant = Range("A2" & lw).SpecialCells(xlCellTypeConstants).Count MsgBox "There are " & MyConstant & " Cells with constants in the Range " For i = 1 To lw If Range("A" & i).Interior.ColorIndex = 36 Then counter = counter + 1 End If Next MsgBox counter End Sub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi
you might also check this site out for color IDF's. count, sum, sort, other. http://cpearson.com/excel/colors.aspx regards FSt1 "oldjay" wrote: First I want to count the number of cells in a range that have text in them. Then I want to count how many of these cells have the back ground color 36 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I should have been more explicit in my request. First I want to count the
number of cells in a range (A1:F30) that have text in them (there will only be text or blank). Then I want to count all the cell that have a background of color 36. I then want to export these results to cells H1 and H2. "marcus" wrote: Oldjay This will achieve what you want for a continuous range, Column A in this example. Change the variables to suit. Take care Marcus Option Explicit Sub MyCount() Dim lw As Integer Dim counter As Integer Dim MyConstant As Integer Dim i As Integer lw = Range("A" & Rows.Count).End(xlUp).Row counter = 0 MyConstant = Range("A2" & lw).SpecialCells(xlCellTypeConstants).Count MsgBox "There are " & MyConstant & " Cells with constants in the Range " For i = 1 To lw If Range("A" & i).Interior.ColorIndex = 36 Then counter = counter + 1 End If Next MsgBox counter End Sub . |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Oldjay
Sorry for the delay - weekend and well away from the computer. This should do what you want. Enjoy your weekend. Change the variables, such as sheet name to suit. Take care Marcus Option Explicit Sub MyCount() Dim lw As Integer Dim MyConstant As Integer Dim Counter As Integer Dim rRange As Range Dim rCell As Range Set rRange = Range("A1:F30") lw = Range("A" & Rows.Count).End(xlUp).Row MyConstant = Application.CountA(Sheets("Sheet1").Range("A1:F30" )) Range("H1").Value = MyConstant For Each rCell In rRange If rCell.Interior.ColorIndex = 36 Then Counter = 1 + Counter End If Next rCell Range("H2").Value = Counter End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Count cells in range w/specific background color? | Excel Worksheet Functions | |||
count if font and background color condition is true | Excel Worksheet Functions | |||
how to count cells with specific format (background color)? | Excel Discussion (Misc queries) | |||
How do you count cells with background color yellow? | Excel Discussion (Misc queries) | |||
Need help with complicated use of count background color of Cell | Excel Programming |