Excel VBA对具有匹配条件的所有单元格求和

时间:2018-08-27 13:12:22

标签: excel vba excel-vba excel-formula excel-2010

我一直在尝试进行总体设备效率(OEE),为此,我需要能够对所有好的产品进行汇总,然后将其除以总产量。这样我就得到了优质的INDEX ...

条件是“今天”,班次(1或2或3),件号

到目前为止,我已经做到了...

Private Sub CommandButton1_Click()

    Dim last, i As Integer
    Dim ref As String, turno As String, dia As String, estado As String, pecasap As String, pecaspr As String

    'Sheets("analisegeral").Select

    folha = estadoform.Label1.Caption
    last = Application.ThisWorkbook.Worksheets(folha).Range("A65536").End(xlUp).Row


    Application.ThisWorkbook.Worksheets(folha).Cells(last + 1, 5) = fimturnoform.ComboBox1 'peça
    Application.ThisWorkbook.Worksheets(folha).Cells(last + 1, 6) = "FIM TURNO"
    Application.ThisWorkbook.Worksheets(folha).Cells(last + 1, 7) = "FINALIZADO" 'estado trabalho (A DECORRER/FINALIZADO)
    Application.ThisWorkbook.Worksheets(folha).Cells(last + 1, 9) = fimturnoform.TextBox1.Text 'fase
    Application.ThisWorkbook.Worksheets(folha).Cells(last + 1, 12) = Now() 'HORA FIM TURNO
    Application.ThisWorkbook.Worksheets(folha).Cells(last + 1, 14) = fimturnoform.TextBox3.Text 'peças aprovadas
    Application.ThisWorkbook.Worksheets(folha).Cells(last + 1, 15) = fimturnoform.TextBox2.Text 'peças produzidas


    '' Day (Now)

    For i = 2 To last
        dia = Cells(i, 3)
        turno = Cells(i, 4)
        ref = Cells(i, 5)
        estado = Cells(i, 6)
        pecasap
        pecaspr
        If (Day(Now) = dia And ComboBox2 = turno And ComboBox1 = ref And (estado = "FIM LOTE" Or estado = "FIM TURNO")) Then

        End If
    Next i

    GoTo fim
    fim:

End Sub

0 个答案:

没有答案