---
title: "Räkna celler med bakgrundsfärg"
type: "forum-thread"
url: "https://www.webforum.nu/amne/kontorsprogram/160080-räkna-celler-med-bakgrundsfärg"
topic: "Kontorsprogram"
topic_url: "https://www.webforum.nu/amne/kontorsprogram"
author: "Web-Tor"
published: "2007-05-09T10:46:52.000Z"
updated: "2007-05-09T11:17:25.000Z"
replies: 2
views: 401
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/kontorsprogram/160080-räkna-celler-med-bakgrundsfärg"
---

# Räkna celler med bakgrundsfärg

## #1 — Web-Tor, 2007-05-09T10:46Z

Kan man i Excel räkna alla celler i en kolumn som har en viss bakgrundsfärg?

Permalänk: https://www.webforum.nu/p/160080

## #2 — soopafly, 2007-05-09T10:53Z

Javisst - med VBA

```
Function CountByColor(InRange As Range, _
    WhatColorIndex As Integer, _
    Optional OfText As Boolean = False) As Long
'
' This function return the number of cells in InRange with 
' a background color, or if OfText is True a font color, 
' equal to WhatColorIndex.
'
Dim Rng As Range
Application.Volatile True

For Each Rng In InRange.Cells
If OfText = True Then
    CountByColor = CountByColor -  _ 
            (Rng.Font.ColorIndex = WhatColorIndex)
Else
    CountByColor = CountByColor -  _ 
       (Rng.Interior.ColorIndex = WhatColorIndex)
End If
Next Rng

End Function

You can call this function from a worksheet cell with a formula like
=COUNTBYCOLOR(A1:A10,3,FALSE)
```

<http://www.cpearson.com/excel/colors.htm>

.. och om CF har använts: <http://www.cpearson.com/excel/CFColors.htm>

Permalänk: https://www.webforum.nu/p/1973109

## #3 — Web-Tor, 2007-05-09T11:17Z

Oj! :o

Permalänk: https://www.webforum.nu/p/1973120

---

Tråden på webben: https://www.webforum.nu/amne/kontorsprogram/160080-räkna-celler-med-bakgrundsfärg
