返回列表 上一主題 發帖

請問怎樣將不同色彩數目相加

只分早、午、晚, 不分會議室A、B、C嗎?

TOP

不知道 VBA 可不可以接受?
'注意:為了日期的可擴展性, 原 J1:J3 已移至 B16:B18
'請根據需要, 自行更改
Private Sub CommandButton1_Click()
    Dim Ar
    Dim R1 As Integer, C1 As Integer, LstC As Integer, CN As Integer
    Dim MC As Integer, AC As Integer, EC As Integer
   
    [B11:H13] = ""
    LstC = [IV2].End(xlToLeft).Column
    MC = [B16].Font.ColorIndex   '上午顏色
    AC = [B17].Font.ColorIndex   '下午顏色
    EC = [B18].Font.ColorIndex   '晩上顏色
   
    For R1 = 2 To 8
        For C1 = 2 To LstC
            If Cells(R1, C1) <> "" Then
                CN = Cells(R1, C1).Font.ColorIndex
                If CN = MC Then
                    Cells(11, C1) = Cells(11, C1) + Cells(R1, C1)
                ElseIf CN = AC Then
                    Cells(12, C1) = Cells(12, C1) + Cells(R1, C1)
                Else
                    Cells(13, C1) = Cells(13, C1) + Cells(R1, C1)
                End If
            End If
        Next
    Next
End Sub
test.gif

TOP

        靜思自在 : 有智慧才能分辨善惡邪正;有謙虛才能建立美滿人生。
返回列表 上一主題