VBA多重if函数,不排除下一个

VBA多重if函数,不排除下一个,vba,if-statement,outlook,Vba,If Statement,Outlook,我有三个if函数,但我不希望它们相互排斥 例如: ReportArray(5, Mailcounter) = 1 ReportArray(11, Mailcounter) = 0 ReportArray(17, Mailcounter) = 1 上面的示例应该包括四个first.HTMLBody和最后四个.HTMLBody 代码 如果ReportArray(5,Mailcounter)>0,则 .HTMLBody=.HTMLBody&“”和“3.2.3-3.2.4绿化和灌溉

我有三个if函数,但我不希望它们相互排斥

例如:

ReportArray(5, Mailcounter) = 1    
ReportArray(11, Mailcounter) = 0    
ReportArray(17, Mailcounter) = 1  
上面的示例应该包括四个first.HTMLBody和最后四个.HTMLBody

代码

如果ReportArray(5,Mailcounter)>0,则
.HTMLBody=.HTMLBody&“

”和“3.2.3-3.2.4绿化和灌溉系统”和“

” .HTMLBody=.HTMLBody&“
  • ”和“+”&报告数组(3,Mailcounter)和“&CurrencySheet.Range”(“A”&国家货币)和“+”在“+”&报告数组(5,Mailcounter)和“&CurrencySheet.Range”(“A”)中&CountryCurrency)和“+”在园林绿化和灌溉系统中作为一个整体 .HTMLBody=.HTMLBody&“

  • ”和“关于我们的数据”,“3.2.3-3.2.4景观美化和灌溉系统”应该有“+”&格式(ReportArray(7,Mailcounter),“0.0%”和“整个景观美化和灌溉系统”。&“

  • ” .HTMLBody=.HTMLBody&“
  • ”&“因此,我们希望您确认这是否属实-如果是,请在您的输入表中将“&ReportArray(8,Mailcounter)&”分配给“绿化和灌溉系统-SBTB”。&“

” 如果ReportArray(11,Mailcounter)>0,则 .HTMLBody=.HTMLBody&“

”和“3.2.11室内植物和树木维护”和“

” .HTMLBody=.HTMLBody&“
  • ”和“您当前有”+”&ReportArray(9,Mailcounter)和“&CurrencySheet.Range”(“A”&CountryCurrency)和“+”在“+”&ReportArray(11,Mailcounter)和“&CurrencySheet.Range”(“A”)中&CountryCurrency)和“+”作为一个整体用于室内植物和树木维护 .HTMLBody=.HTMLBody&“

  • ”和“关于我们的数据”,“3.2.11内部植物和树木维护”应该有“+”&格式(ReportArray(12,Mailcounter),“0.0%”和“&”的内部植物和树木维护总量 .HTMLBody=.HTMLBody&“因此,我们希望您确认这是否属实,如果是,请在您的输入表中将“&ReportArray(13,Mailcounter)&”分配给“绿化和灌溉系统-SBTB”。&“

” 如果ReportArray(17,Mailcounter)>0,则 .HTMLBody=.HTMLBody&“

”和“3.3.10内部害虫控制”和“

” .HTMLBody=.HTMLBody&“
  • ”和“您当前在“+”和“报告数组(15,Mailcounter)和“&CurrencySheet.Range”(“A”和“CountryCurrency”)中有“+”和“&CurrencySheet.Range”(“A”和“&CountryCurrency”)和“+”+“室内有害生物控制总计”和“

  • ” .HTMLBody=.HTMLBody&“
  • ”和“就我们的数据而言,“3.3.10内部害虫控制”应具有“+”&格式(ReportArray(19,Mailcounter),“0.0%”和“内部害虫控制总量”。&“

  • ” .HTMLBody=.HTMLBody&“因此,我们希望您确认这是否属实,如果是,请在您的输入表中将“&ReportArray(20,Mailcounter)&”分配给“绿化和灌溉系统-SBTB”。&“

    ” 如果结束 如果结束 如果结束
您需要使每个if语句都是自己的。在以下情况下,在每个情况之后移动结束if:

    If ReportArray(5, Mailcounter) > 0 Then
        .HTMLBody = .HTMLBody & "<p style='font-family:Calibri, sans-serif;font-size:18'><B><U>" & "3.2.3-3.2.4 Landscaping & Irrigation System" & "</U></B></p>"
        .HTMLBody = .HTMLBody & "<ul><li><p style='font-family:Calibri, sans-serif;font-size:16'>" & "You currently have " + "<U>" & ReportArray(3, Mailcounter) & " " & CurrencySheet.Range("A" & CountryCurrency) & "</U>" + " in ""3.2.3-3.2.4 Landscaping & Irrigation System"" out of " + "<U>" & ReportArray(5, Mailcounter) & " " & CurrencySheet.Range("A" & CountryCurrency) & "</U>" + " in Landscaping & Irrigation System as a total." & "</p></li>"
        .HTMLBody = .HTMLBody & "<li><p style='font-family:Calibri, sans-serif;font-size:16'>" & "With regards to our data, ""3.2.3-3.2.4 Landscaping & Irrigation System"" are supposed to have " + "<U>" & Format(ReportArray(7, Mailcounter), "0.0 %") & "</U>" & " of the total Landscaping & Irrigation System." & "</p></li>"
        .HTMLBody = .HTMLBody & "<li><p style='font-family:Calibri, sans-serif;font-size:16'>" & "We would therefore like you to confirm whether this is true - and if yes, allocate " & ReportArray(8, Mailcounter) & " to ""Landscaping & Irrigation System - SBTB"" in your input sheet." & "</p></li></ul>"
    End If
    If ReportArray(11, Mailcounter) > 0 Then
        .HTMLBody = .HTMLBody & "<p style='font-family:Calibri, sans-serif;font-size:18'><B><U>" & "3.2.11 Interior Plant and Tree Maintenance" & "</U></B></p>"
        .HTMLBody = .HTMLBody & "<ul><li><p style='font-family:Calibri, sans-serif;font-size:16'>" & "You currently have " + "<U>" & ReportArray(9, Mailcounter) & " " & CurrencySheet.Range("A" & CountryCurrency) & "</U>" + " in ""3.2.11 Interior Plant and Tree Maintenance"" out of " + "<U>" & ReportArray(11, Mailcounter) & " " & CurrencySheet.Range("A" & CountryCurrency) & "</U>" + " in Interior Plant and Tree Maintenance as a total." & "</p></li>"
        .HTMLBody = .HTMLBody & "<li><p style='font-family:Calibri, sans-serif;font-size:16'>" & "With regards to our data, ""3.2.11 Interior Plant and Tree Maintenance"" are supposed to have " + "<U>" & Format(ReportArray(12, Mailcounter), "0.0 %") & "</U>" & " of the total Interior Plant and Tree Maintenance." & "</p></li>"
        .HTMLBody = .HTMLBody & "<li><p style='font-family:Calibri, sans-serif;font-size:16'>" & "We would therefore like you to confirm whether this is true - and if yes, allocate " & ReportArray(13, Mailcounter) & " to ""Landscaping & Irrigation System - SBTB"" in your input sheet." & "</p></li></ul>"
    End If
    If ReportArray(17, Mailcounter) > 0 Then
        .HTMLBody = .HTMLBody & "<p style='font-family:Calibri, sans-serif;font-size:18'><B><U>" & "3.3.10 Interior Pest Control" & "</U></B></p>"
        .HTMLBody = .HTMLBody & "<ul><li><p style='font-family:Calibri, sans-serif;font-size:16'>" & "You currently have " + "<U>" & ReportArray(15, Mailcounter) & " " & CurrencySheet.Range("A" & CountryCurrency) & "</U>" + " in ""3.3.10 Interior Pest Control"" out of " + "<U>" & ReportArray(17, Mailcounter) & " " & CurrencySheet.Range("A" & CountryCurrency) & "</U>" + " in Interior Pest Control as a total." & "</p></li>"
        .HTMLBody = .HTMLBody & "<li><p style='font-family:Calibri, sans-serif;font-size:16'>" & "With regards to our data, ""3.3.10 Interior Pest Control"" are supposed to have " + "<U>" & Format(ReportArray(19, Mailcounter), "0.0 %") & "</U>" & " of the total Interior Pest Control." & "</p></li>"
        .HTMLBody = .HTMLBody & "<li><p style='font-family:Calibri, sans-serif;font-size:16'>" & "We would therefore like you to confirm whether this is true - and if yes, allocate " & ReportArray(20, Mailcounter) & " to ""Landscaping & Irrigation System - SBTB"" in your input sheet." & "</p></li>"
    End If
如果ReportArray(5,Mailcounter)>0,则
.HTMLBody=.HTMLBody&“

”和“3.2.3-3.2.4绿化和灌溉系统”和“

” .HTMLBody=.HTMLBody&“
  • ”和“+”&报告数组(3,Mailcounter)和“&CurrencySheet.Range”(“A”&国家货币)和“+”在“+”&报告数组(5,Mailcounter)和“&CurrencySheet.Range”(“A”)中&CountryCurrency)和“+”在园林绿化和灌溉系统中作为一个整体 .HTMLBody=.HTMLBody&“

  • ”和“关于我们的数据”,“3.2.3-3.2.4景观美化和灌溉系统”应该有“+”&格式(ReportArray(7,Mailcounter),“0.0%”和“整个景观美化和灌溉系统”。&“

  • ” .HTMLBody=.HTMLBody&“
  • ”&“因此,我们希望您确认这是否属实-如果是,请在您的输入表中将“&ReportArray(8,Mailcounter)&”分配给“绿化和灌溉系统-SBTB”。&“

” 如果结束 如果ReportArray(11,Mailcounter)>0,则 .HTMLBody=.HTMLBody&“

”和“3.2.11室内植物和树木维护”和“

” .HTMLBody=.HTMLBody&“
  • ”和“您当前有”+”&ReportArray(9,Mailcounter)和“&CurrencySheet.Range”(“A”&CountryCurrency)和“+”在“+”&ReportArray(11,Mailcounter)和“&CurrencySheet.Range”(“A”)中&CountryCurrency)和内部设备a中的“+”

        If ReportArray(5, Mailcounter) > 0 Then
            .HTMLBody = .HTMLBody & "<p style='font-family:Calibri, sans-serif;font-size:18'><B><U>" & "3.2.3-3.2.4 Landscaping & Irrigation System" & "</U></B></p>"
            .HTMLBody = .HTMLBody & "<ul><li><p style='font-family:Calibri, sans-serif;font-size:16'>" & "You currently have " + "<U>" & ReportArray(3, Mailcounter) & " " & CurrencySheet.Range("A" & CountryCurrency) & "</U>" + " in ""3.2.3-3.2.4 Landscaping & Irrigation System"" out of " + "<U>" & ReportArray(5, Mailcounter) & " " & CurrencySheet.Range("A" & CountryCurrency) & "</U>" + " in Landscaping & Irrigation System as a total." & "</p></li>"
            .HTMLBody = .HTMLBody & "<li><p style='font-family:Calibri, sans-serif;font-size:16'>" & "With regards to our data, ""3.2.3-3.2.4 Landscaping & Irrigation System"" are supposed to have " + "<U>" & Format(ReportArray(7, Mailcounter), "0.0 %") & "</U>" & " of the total Landscaping & Irrigation System." & "</p></li>"
            .HTMLBody = .HTMLBody & "<li><p style='font-family:Calibri, sans-serif;font-size:16'>" & "We would therefore like you to confirm whether this is true - and if yes, allocate " & ReportArray(8, Mailcounter) & " to ""Landscaping & Irrigation System - SBTB"" in your input sheet." & "</p></li></ul>"
        End If
        If ReportArray(11, Mailcounter) > 0 Then
            .HTMLBody = .HTMLBody & "<p style='font-family:Calibri, sans-serif;font-size:18'><B><U>" & "3.2.11 Interior Plant and Tree Maintenance" & "</U></B></p>"
            .HTMLBody = .HTMLBody & "<ul><li><p style='font-family:Calibri, sans-serif;font-size:16'>" & "You currently have " + "<U>" & ReportArray(9, Mailcounter) & " " & CurrencySheet.Range("A" & CountryCurrency) & "</U>" + " in ""3.2.11 Interior Plant and Tree Maintenance"" out of " + "<U>" & ReportArray(11, Mailcounter) & " " & CurrencySheet.Range("A" & CountryCurrency) & "</U>" + " in Interior Plant and Tree Maintenance as a total." & "</p></li>"
            .HTMLBody = .HTMLBody & "<li><p style='font-family:Calibri, sans-serif;font-size:16'>" & "With regards to our data, ""3.2.11 Interior Plant and Tree Maintenance"" are supposed to have " + "<U>" & Format(ReportArray(12, Mailcounter), "0.0 %") & "</U>" & " of the total Interior Plant and Tree Maintenance." & "</p></li>"
            .HTMLBody = .HTMLBody & "<li><p style='font-family:Calibri, sans-serif;font-size:16'>" & "We would therefore like you to confirm whether this is true - and if yes, allocate " & ReportArray(13, Mailcounter) & " to ""Landscaping & Irrigation System - SBTB"" in your input sheet." & "</p></li></ul>"
        End If
        If ReportArray(17, Mailcounter) > 0 Then
            .HTMLBody = .HTMLBody & "<p style='font-family:Calibri, sans-serif;font-size:18'><B><U>" & "3.3.10 Interior Pest Control" & "</U></B></p>"
            .HTMLBody = .HTMLBody & "<ul><li><p style='font-family:Calibri, sans-serif;font-size:16'>" & "You currently have " + "<U>" & ReportArray(15, Mailcounter) & " " & CurrencySheet.Range("A" & CountryCurrency) & "</U>" + " in ""3.3.10 Interior Pest Control"" out of " + "<U>" & ReportArray(17, Mailcounter) & " " & CurrencySheet.Range("A" & CountryCurrency) & "</U>" + " in Interior Pest Control as a total." & "</p></li>"
            .HTMLBody = .HTMLBody & "<li><p style='font-family:Calibri, sans-serif;font-size:16'>" & "With regards to our data, ""3.3.10 Interior Pest Control"" are supposed to have " + "<U>" & Format(ReportArray(19, Mailcounter), "0.0 %") & "</U>" & " of the total Interior Pest Control." & "</p></li>"
            .HTMLBody = .HTMLBody & "<li><p style='font-family:Calibri, sans-serif;font-size:16'>" & "We would therefore like you to confirm whether this is true - and if yes, allocate " & ReportArray(20, Mailcounter) & " to ""Landscaping & Irrigation System - SBTB"" in your input sheet." & "</p></li>"
        End If