merhabalar üstadların konularından faydalanarak renk toplamı yapabildim fakat koşullu biçimlendirme yapılan hücrelerde renk değişince toplamlar değişmiyor bunu nasıl ayarlayabilirim?Yardımlarınız için şimdididen teşekkürler...
DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
Altın Üyelik Hakkında Bilgi
Function RenkTopla(Alan As Range, RenkliHucre As Range) As Variant
Dim RenkliAlan As Range
Dim Sonuc
Dim Renk
Application.Volatile
On Error GoTo Son
Renk = RenkliHucre.Interior.Color
For Each RenkliAlan In Alan
If Renk = RenkliAlan.Interior.Color Then Sonuc = Sonuc + RenkliAlan.Value
Next
Son:
RenkTopla = Sonuc
End Function
Sub renkli_hücreleri_topla()
say1 = 0
say2 = 0
say3 = 0
For i = 2 To Cells(Rows.Count, "e").End(3).Row
If Cells(i, "e").FormatConditions.Count = 1 Then
If Cells(i, "e").FormatConditions(1).Interior.ColorIndex = 3 Then
say1 = say1 + CDbl(Cells(i, "e").Value)
End If
If Cells(i, "e").FormatConditions(1).Interior.ColorIndex = 6 Then
say2 = say2 + CDbl(Cells(i, "e").Value)
End If
If Cells(i, "e").FormatConditions(1).Interior.ColorIndex = 42 Then
say3 = say3 + CDbl(Cells(i, "e").Value)
End If
End If
If Cells(i, "e").FormatConditions.Count = 2 Then
If Cells(i, "e").FormatConditions(1).Interior.ColorIndex = 3 Then
say1 = say1 + CDbl(Cells(i, "e").Value)
End If
If Cells(i, "e").FormatConditions(2).Interior.ColorIndex = 3 Then
say1 = say1 + CDbl(Cells(i, "e").Value)
End If
If Cells(i, "e").FormatConditions(1).Interior.ColorIndex = 6 Then
say2 = say2 + CDbl(Cells(i, "e").Value)
End If
If Cells(i, "e").FormatConditions(2).Interior.ColorIndex = 6 Then
say2 = say2 + CDbl(Cells(i, "e").Value)
End If
If Cells(i, "e").FormatConditions(1).Interior.ColorIndex = 42 Then
say3 = say3 + CDbl(Cells(i, "e").Value)
End If
If Cells(i, "e").FormatConditions(2).Interior.ColorIndex = 42 Then
say3 = say3 + CDbl(Cells(i, "e").Value)
End If
End If
If Cells(i, "e").FormatConditions.Count = 3 Then
If Cells(i, "e").FormatConditions(1).Interior.ColorIndex = 3 Then
say1 = say1 + CDbl(Cells(i, "e").Value)
End If
If Cells(i, "e").FormatConditions(2).Interior.ColorIndex = 3 Then
say1 = say1 + CDbl(Cells(i, "e").Value)
End If
If Cells(i, "e").FormatConditions(3).Interior.ColorIndex = 3 Then
say1 = say1 + CDbl(Cells(i, "e").Value)
End If
If Cells(i, "e").FormatConditions(1).Interior.ColorIndex = 6 Then
say2 = say2 + CDbl(Cells(i, "e").Value)
End If
If Cells(i, "e").FormatConditions(2).Interior.ColorIndex = 6 Then
say2 = say2 + CDbl(Cells(i, "e").Value)
End If
If Cells(i, "e").FormatConditions(3).Interior.ColorIndex = 6 Then
say2 = say2 + CDbl(Cells(i, "e").Value)
End If
If Cells(i, "e").FormatConditions(1).Interior.ColorIndex = 42 Then
say3 = say3 + CDbl(Cells(i, "e").Value)
End If
If Cells(i, "e").FormatConditions(2).Interior.ColorIndex = 42 Then
say3 = say3 + CDbl(Cells(i, "e").Value)
End If
If Cells(i, "e").FormatConditions(3).Interior.ColorIndex = 42 Then
say3 = say3 + CDbl(Cells(i, "e").Value)
End If
End If
Next i
Cells(29, "e").Value = say1
Cells(30, "e").Value = say2
Cells(31, "e").Value = say3
MsgBox "işlem tamam"
End Sub
Sub RENGE_GÖRE_TOPLA()
Dim Veri As Range, Toplam As Double, Renk As Byte
Renk = 3
For Each Veri In Range("E2:E20")
If Veri.DisplayFormat.Interior.ColorIndex = Renk Then
Toplam = Toplam + Veri.Value
End If
Next
Range("F30") = Toplam
End Sub
Kullandığınız kodlar hücrenin fiziksel rengine göre işlem yapar. Fakat siz koşullu biçimlendirme olan hücrelerdeki değerleri renklerine göre toplamak istiyorsunuz.
Bunun için Halit beyin önerdiği kodu kullanabilirsiniz. Ya da alternatif olarak aşağıdaki kodu da deneyebilirsiniz.
Kod:Sub RENGE_GÖRE_TOPLA() Dim Veri As Range, Toplam As Double, Renk As Byte Renk = 3 For Each Veri In Range("E2:E20") If Veri.DisplayFormat.Interior.ColorIndex = Renk Then Toplam = Toplam + Veri.Value End If Next Range("F30") = Toplam End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Uygulama As Object, K1 As Object, S1 As Worksheet, Dosya As String
If Intersect(Target, Range("F1")) Is Nothing Then Exit Sub
If Target = "ericsson" Then
Application.ScreenUpdating = False
Set Uygulama = CreateObject("Excel.Application")
Uygulama.Visible = False
Dosya = ThisWorkbook.Path & "\Kitap2.xlsx"
Set K1 = Uygulama.Workbooks.Open(Dosya, False, False)
Set S1 = K1.Worksheets("Sayfa1")
S1.Range("A1") = CDate(Range("A1"))
S1.Range("A:A").EntireColumn.AutoFit
K1.Save
K1.Close 0
Set S1 = Nothing
Set K1 = Nothing
Set Uygulama = Nothing
Application.ScreenUpdating = True
End If
End Sub