Excel vba如何检查双栏组合的值

Excel vba如何检查双栏组合的值,excel,vba,Excel,Vba,我有一个双栏组合,我使用第(1)栏中的值作为我的答案,但是当我想用这个代码检查该组合是否有值时,它不会执行,所以当我试图从组合中检索值时,我会得到运行时错误381。 这是我的密码 If Trim(CmBCodes.Value) = "" Then MsgBox "Please fill in the journey Code" CmBCodes.SetFocus Exit Sub End If 然后改成了这个 If Trim(CmBCodes.Value

我有一个双栏组合,我使用第(1)栏中的值作为我的答案,但是当我想用这个代码检查该组合是否有值时,它不会执行,所以当我试图从组合中检索值时,我会得到运行时错误381。 这是我的密码

 If Trim(CmBCodes.Value) = "" Then
    MsgBox "Please fill in the journey Code"
    CmBCodes.SetFocus
    Exit Sub
    End If
然后改成了这个

   If Trim(CmBCodes.Value) = Null And Len(CmBCodes.Value)) = Null Then
    MsgBox "Please fill in the journey Code"
    CmBCodes.SetFocus
    Exit Sub
    End If
即使组合没有选择任何值,这个代码也不会执行,所以它会一直运行到代码段,在那里我尝试检索值,并在这里抛出一个错误381

  ws.Cells(iRow, 2).Value = UCase(CmBCodes.Column(1))

如果未进行选择,则组合框和列表框的listindex为-1

If CmBCodes.ListIndex = -1  Then
    MsgBox "Please fill in the journey Code"
    CmBCodes.SetFocus
    Exit Sub
End If

如果未进行选择,则组合框和列表框的listindex为-1

If CmBCodes.ListIndex = -1  Then
    MsgBox "Please fill in the journey Code"
    CmBCodes.SetFocus
    Exit Sub
End If