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

时间:2017-04-13 17:00:46

标签: excel-vba variables worksheet-function vba excel

我想使用CountIf函数,但是如果我的任何一个变量(a或B)都是空白(userform组合框没有用值选择),则该函数不会计算。下面列出的是CountIfs函数。我想忽略" D"变量如果为空且仍为Countif

Public Sub CommandButton1_Click()

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)

卸载我

End Sub

0 个答案:

没有答案