Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
calling for help again for xls 2003
Hello to all,
I got a mystical problem in tracking the bulk of continuous changes made in a monitoring worksheet. I need to count the number of cells in a worksheet that contains a specific color of text. e.g In A1 contains text like this "The quick brown fox jumps over the lazy dog." if the text "lazy dog" is colored red while the others are in black or blue or whatever, is it possible to count A1 as part of the cells that has red text in it...by macro.? I hope that this is possible, otherwise I am caught in a big mess counting with my fingers these cells with red text in a group of text along thousands of cells. thanks for any advice or suggestion. -- regards, |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
calling for help again for xls 2003
Try this out :) I've tested it and it worked for me, you might need to change
the If check for the colour, as I was going off the colour index 3 which is a bright red. Unsure about that. Sub CountInstancesOfRed() Dim count As Integer Dim i As Integer Dim strLen As Integer Dim aRange As Range Set aRange = Sheet1.Range("A1:A10") For Each c In aRange strLen = Len(c.Value) For i = 1 To strLen With c.Characters(Start:=i, Length:=1).Font If .ColorIndex = 3 Then count = count + 1 Exit For End If End With Next i Next c MsgBox count End Sub "driller" wrote: Hello to all, I got a mystical problem in tracking the bulk of continuous changes made in a monitoring worksheet. I need to count the number of cells in a worksheet that contains a specific color of text. e.g In A1 contains text like this "The quick brown fox jumps over the lazy dog." if the text "lazy dog" is colored red while the others are in black or blue or whatever, is it possible to count A1 as part of the cells that has red text in it...by macro.? I hope that this is possible, otherwise I am caught in a big mess counting with my fingers these cells with red text in a group of text along thousands of cells. thanks for any advice or suggestion. -- regards, |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
calling for help again for xls 2003
tnaks and sorry for a late reply,
i've tested the macro, the pop-up result always shows a "0". I may have missed something. -- regards, "NateBuckley" wrote: Try this out :) I've tested it and it worked for me, you might need to change the If check for the colour, as I was going off the colour index 3 which is a bright red. Unsure about that. Sub CountInstancesOfRed() Dim count As Integer Dim i As Integer Dim strLen As Integer Dim aRange As Range Set aRange = Sheet1.Range("A1:A10") For Each c In aRange strLen = Len(c.Value) For i = 1 To strLen With c.Characters(Start:=i, Length:=1).Font If .ColorIndex = 3 Then count = count + 1 Exit For End If End With Next i Next c MsgBox count End Sub "driller" wrote: Hello to all, I got a mystical problem in tracking the bulk of continuous changes made in a monitoring worksheet. I need to count the number of cells in a worksheet that contains a specific color of text. e.g In A1 contains text like this "The quick brown fox jumps over the lazy dog." if the text "lazy dog" is colored red while the others are in black or blue or whatever, is it possible to count A1 as part of the cells that has red text in it...by macro.? I hope that this is possible, otherwise I am caught in a big mess counting with my fingers these cells with red text in a group of text along thousands of cells. thanks for any advice or suggestion. -- regards, |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Calling a sub | Excel Programming | |||
Excel 2003 VBA calling VB.NET ? | Excel Programming | |||
Calling functions developed in VSTO 2005 from Office Excel 2003 | Excel Programming | |||
Calling Solver from an Excel 2003 Macro | Excel Programming | |||
Calling from C#.Net App Office._CommandBarButton.Execute() method in Excel 2003 throws a COMException | Excel Programming |