使用 VBA 计算百分比
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41510066/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 11:49:31 来源:igfitidea点击:
Calculating percentage using VBA
提问by walter while
I need to calculate the percentage for the below code.
我需要计算以下代码的百分比。
Cell AE43 gives the total count out.
单元格 AE43 给出了总计数。
Cell AE51 gives valid count.
单元格 AE51 给出有效计数。
Cell AE53 should hold the % for this.
单元格 AE53 应为此保留 %。
Sub WBR()
Dim Count1Criteria As Variant
Dim Count3Criteria As Variant
Dim test As Variant
Dim wf As WorksheetFunction
Set wf = Application.WorksheetFunction
Filter1InSummary = Array(Array("AE4", "Latency", "O:O", "Pass"), _
Array("AE51", "TT", "G:G", "Yes"), _
Array("AE52", "TT", "G:G", "No"), _
Array("AE61", "Reactive", "R:R", "Item"))
Filter3InSummary = Array(Array("AE43", "TT", "I:I", "<>Duplicate TT", _
"G:G", "<>Not Tested", _
"U:U", "Item"))
For Each test In Filter3InSummary
With Worksheets(test(1))
Range(test(0)) = wf.CountIfs(.Range(test(2)), test(3), _
.Range(test(4)), test(5), _
.Range(test(6)), test(7))
End With
Next