Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel 如何忽略要在工作表函数中使用的组合框中的空白值?_Excel_Variables_Worksheet Function_Vba - Fatal编程技术网

Excel 如何忽略要在工作表函数中使用的组合框中的空白值?

Excel 如何忽略要在工作表函数中使用的组合框中的空白值?,excel,variables,worksheet-function,vba,Excel,Variables,Worksheet Function,Vba,我想使用CountIf函数,但如果我的任一变量(a或B)为空(userform combobox未选择值),则该函数不会计算。下面列出的是CountIfs功能。如果“D”变量为空且仍然Countif,我想忽略它 公共子命令按钮1_单击() 卸下我 结束子部分请添加其余代码,什么是D?它是如何得到它的值的?更新了从C&D到a&B的变量。如果未选择combobox1,我希望函数仍然计算或使用countif函数,但在为空时不出错。 Dim C As String Dim LastTarget As r

我想使用
CountIf
函数,但如果我的任一变量(a或B)为空(userform combobox未选择值),则该函数不会计算。下面列出的是
CountIfs
功能。如果“D”变量为空且仍然
Countif
,我想忽略它

公共子命令按钮1_单击()

卸下我


结束子部分

请添加其余代码,什么是
D
?它是如何得到它的值的?更新了从C&D到a&B的变量。如果未选择combobox1,我希望函数仍然计算或使用countif函数,但在为空时不出错。
Dim C As String
Dim LastTarget As range
Dim LastTarget2 As range

Set LastTarget = ActiveCell
Set LastTarget2 = ActiveCell.Offset(0, 3)

Set wb1 = Workbooks("Userform 4.3.xlsm")


a = ComboBoxA.value
B = ComboBox1.value

'Counts & Coverages based on plan code selection
LastTarget = Application.CountIfs(wb1.Sheets("Carrier").range("BG:BG"), a, wb1.Sheets("Carrier").range("AH:AH"), B)