Hirdetés

Új hozzászólás Aktív témák

  • Talala

    senior tag

    válasz Talala #53719 üzenetére

    Ez lenne a másik, ami ugyan számolná a feltételes formázással színezett cellákat is, de kézzel kell futtatni és kijelölni a területet stb. A végén pedig egy msg boxba adja az eredményt. Ezt szeretném az első hozzászólásban látottaknak megfelelően cellába írni a hónapok alá.
    Sub SumCountByConditionalFormat()

        Dim sampleColor As Range
        Dim selectedRange As Range
        Dim cell As Range
        Dim countByColor As Long
        Dim sumByColor As Double
        Dim refColor As Long
        Set selectedRange = Application.InputBox("Select a range to evaluate:", _
                                                 "Kutools for Excel", _
                                                 Type:=8)
        If selectedRange Is Nothing Then Exit Sub
        Set sampleColor = Application.InputBox("Select a conditional formatting color:", _
                                               "Kutools for Excel", _
                                               Type:=8)
        If Not sampleColor Is Nothing Then
            refColor = sampleColor.Cells(1, 1).DisplayFormat.Interior.Color
            For Each cell In selectedRange
                If cell.DisplayFormat.Interior.Color = refColor Then
                    countByColor = countByColor + 1
                    sumByColor = sumByColor + cell.Value
                End If
            Next cell
            MsgBox "Count: " & countByColor & vbCrLf & _
                   "Sum: " & sumByColor, _
                   vbInformation, "Results based on Conditional Format Color"
        End If
    End Sub

Új hozzászólás Aktív témák