Moderatori: Anthony47, Flash30005
Public Function COLORE(Cella As Range, indice As Long) As Boolean
If Cella.Interior.ColorIndex <> indice Then
COLORE = False
Else
COLORE = True
End If
End Function
=SE(COLORE(B2:C8;3)=VERO;C2)
Function SumByColor(InRange As Range, WhatColorIndex As Integer, _
Optional OfText As Boolean = False) As Double
'
' This function return the SUM of the values of cells in
' InRange with a background color, or if OfText is True a
' font color, equal to WhatColorIndex.
'
Dim Rng As Range
Dim OK As Boolean
Application.Volatile True
For Each Rng In InRange.Cells
If OfText = True Then
OK = (Rng.Font.ColorIndex = WhatColorIndex)
Else
OK = (Rng.Interior.ColorIndex = WhatColorIndex)
End If
If OK And IsNumeric(Rng.Value) Then
SumByColor = SumByColor + Rng.Value
End If
Next Rng
End Function
Function GetValCol(ShArea As Range, RefCol As Range)
Application.Volatile
For Each Cella In ShArea
If Cella.Interior.ColorIndex = RefCol.Interior.ColorIndex Then
GetValCol = Cella.Value: Exit For
End If
Next Cella
End Function
=GetValCol(D5:J25;A1)
Function GetValCol1(ShArea As Range, ClrIndex As Integer)
Application.Volatile
For Each Cella In ShArea
If Cella.Interior.ColorIndex = ClrIndex Then
GetValCol1 = Cella.Value: Exit For
End If
Next Cella
End Function
=GetValCol1(D5:J25;3)
=GetValCol(D5:J25;A1)
Le due funzioni "volatili", cioe' si ricalcolano a ogni cambiamento nel foglio; tieni pero' presente che una formattazione non e' occasione di ricalcolo, quindi e' opportuno un F9 quando vuoi essere certo che il risultato sia ok.
Torna a Applicazioni Office Windows
Inserimento parziale valore cella in MessageBox Autore: Ricky0185 |
Forum: Applicazioni Office Windows Risposte: 6 |
Inserire add.in nella barra di avvio veloce in excel 2003 Autore: Ricky0185 |
Forum: Applicazioni Office Windows Risposte: 4 |
Aggiornare cella con somma quando aggiungo nuova colonna Autore: marcopont |
Forum: Applicazioni Office Windows Risposte: 1 |
Excel: problema con date se devo unirle a testi Autore: valle1975 |
Forum: Applicazioni Office Windows Risposte: 5 |
Visitano il forum: Nessuno e 10 ospiti