ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   macro that counts lines with certain color (https://www.excelbanter.com/excel-programming/301494-macro-counts-lines-certain-color.html)

Philipp Oberleitner

macro that counts lines with certain color
 
hi all i need a macro that counts the lines with ColorIndex = 3 and gives it
out in a msg box. It should do the same for colorindex 4 and 5.

Thx alot in advance



Philipp Oberleitner

macro that counts lines with certain color
 
Mine doesnt work but i dont know why

Sub StatistikAusgeben()
Const Stat1 = "Open Tickets"
Dim i As Integer
Dim iAnz As Integer
Sheets(Stat1).Activate
Range("A1").Select

iAnz = 0
i = 0

Do Until i = ActiveSheet.UsedRange.Rows.Count
If Selection.Interior.Color = RGB(128, 255, 196) Then
iAnz = iAnz + 1
ActiveCell.Offset(1, 0).Select
Else
ActiveCell.Offset(1, 0).Select
End If
i = i + 1
Loop

MsgBox "Es wurden " & iAnz & " kritische Tickets gefunden"
End Sub


Thx alot



Tom Ogilvy

macro that counts lines with certain color
 
using color is probably the source of your problem. Excel only used 56
colors for cells, so good chance your color is not one of them. Better to
use colorindex

Sub StatistikAusgeben()
Const Stat1 = "Open Tickets"
Dim i As Integer
Dim iAnz As Integer
Sheets(Stat1).Activate
Range("A1").Select

iAnz = 0
i = 0

Do Until i = ActiveSheet.UsedRange.Rows.Count
If Selection.Interior.ColorIndex = 3 Then
iAnz = iAnz + 1
End If
ActiveCell.Offset(1, 0).Select
i = i + 1
Loop

MsgBox "Es wurden " & iAnz & " kritische Tickets gefunden"
End Sub


--
Regards,
Tom Ogilvy

"Philipp Oberleitner" wrote in message
...
Mine doesnt work but i dont know why

Sub StatistikAusgeben()
Const Stat1 = "Open Tickets"
Dim i As Integer
Dim iAnz As Integer
Sheets(Stat1).Activate
Range("A1").Select

iAnz = 0
i = 0

Do Until i = ActiveSheet.UsedRange.Rows.Count
If Selection.Interior.Color = RGB(128, 255, 196) Then
iAnz = iAnz + 1
ActiveCell.Offset(1, 0).Select
Else
ActiveCell.Offset(1, 0).Select
End If
i = i + 1
Loop

MsgBox "Es wurden " & iAnz & " kritische Tickets gefunden"
End Sub


Thx alot






All times are GMT +1. The time now is 10:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com