多个变量的最大值

时间:2017-07-18 07:36:27

标签: excel excel-vba max vba

我正在尝试确定最多2个或3个不同的变量(变体)。 他们都是约会。

Dim QA As Integer: QA = 0
For Each j_WS In Array(WS_1, WS_2, WS3)

    Select Case QA
        Case 0: j = 1
        Case 1: j = 2
        Case 2: j = 3
    End Select

    o = 14 + j * 3

    Dim WA1 As Variant
    Dim WA2 As Variant
    Dim WA3 As Variant
    Gorev = Cells(p, o).Address
    SlideNo = Cells(p, 34).Address
    Egitim_Adi = Cells(2, 3).Address
    Dim Satir_bul As Long

    Satir_bul = Worksheets(WS_All).Evaluate("=Match(" & Egitim_Adi & "&" & SlideNo & "&" & Gorev & ", '" & j_WS & "'!A:A&'" & j_WS & "'!B:B&'" & j_WS & "'!C:C, 0)")

    If j = 1 And Worksheets(WS_All).Cells(8, 3).Value = "Yeni Egitim" Or j = 1 And Worksheets(WS_All).Cells(8, 3).Value = "Tanitim / Reklam" Then
        WA1 = Worksheets(j_WS).Cells(Satir_bul, 7).Value
    Else: WA1 = Worksheets(j_WS).Cells(Satir_bul, 9).Value
        If j = 2 And Worksheets(WS_All).Cells(8, 3).Value = "Yeni Egitim" Or j = 1 And Worksheets(WS_All).Cells(8, 3).Value = "Tanitim / Reklam" Then
            WA2 = Worksheets(j_WS).Cells(Satir_bul, 7).Value
        Else: WA2 = Worksheets(j_WS).Cells(Satir_bul, 9).Value
            If j = 3 And Worksheets(WS_All).Cells(8, 3).Value = "Yeni Egitim" Or j = 1 And Worksheets(WS_All).Cells(8, 3).Value = "Tanitim / Reklam" Then
                WA3 = Worksheets(j_WS).Cells(Satir_bul, 7).Value
            Else: WA3 = Worksheets(j_WS).Cells(Satir_bul, 9).Value

            End If
        End If
    End If

    QA = QA + 1
Next j_WS

If WS_3 = "" And WS_2 = "" And WA1 <> "" Then
    Worksheets(WS_All).Cells(p, 26).Value = WA1

    If WS_3 = "" And WS_2 <> "" And WA1 <> "" And WA2 <> "" Then
        MAX_BITIS1 = WorksheetFunction.Max(WA1, WA2)
        Worksheets(WS_All).Cells(p, 26).Value = MAX_BITIS1

        If WA1 <> "" And WA2 <> "" And WA3 <> "" Then
            MAX_BITIS2 = WorksheetFunction.Max(WA1, WA2, WA3)
            Worksheets(WS_All).Cells(p, 26).Value = MAX_BITIS2
        Else
            Worksheets(WS_All).Cells(p, 26).Value = ""
        End If

    End If

End If

几乎所有东西都是预定义的整数或类似东西,而WA1,WA2和WA3都是日期。

我希望MAX_BITIS和MAX_BITIS2也是约会。

0 个答案:

没有答案