尝试在用户表单中的组合框中打开下拉列表时出现不匹配错误
我读过这个: https://msdn.microsoft.com/en-us/library/aa264979(v=vs.60).aspx (不明白。)
收到错误的子
Private Sub FailureComBox_DropButtonClick()
Dim emptyRow As Long, i As Integer
emptyRow = WorksheetFunction.CountA(Sheets("Fel").Range("A:A")) + 1
For i = 2 To emptyRow
FailureComBox.AddItem Cells(i, "A")
Next i
End Sub
我在行上看到不匹配错误:
FailureComBox.AddItem Cells(i, "A")
我的用户表单的完整代码
Private Sub BackCB_Click()
Unload Me
UserForm1.Show
End Sub
Private Sub ExitCB_Click()
Unload Me
End Sub
Private Sub FailureComBox_Change()
FailureComBox.Text = FailureComBox.Value
End Sub
Private Sub FailureComBox_DropButtonClick()
Dim emptyRow As Long, i As Integer
emptyRow = WorksheetFunction.CountA(Sheets("Fel").Range("A:A")) + 1
For i = 2 To emptyRow
FailureComBox.AddItem Cells(i, "A")
Next i
End Sub
Private Sub OkCB_Click()
Dim emptyRow As Long
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
If IsDate(DateTB) = False Then
MsgBox "Var vänlig ange ett korrekt datum"
ElseIf FailureComBox <> "" And StopComBox <> "" Then
MsgBox "Var vänlig välj bara ett stopp eller fel."
Else
Cells(emptyRow, 1).Value = DateTB.Value
If SLD000OB = True Then
Cells(emptyRow, 2).Value = SLD00OB.Caption
If SLD00OB = True Then
Cells(emptyRow, 2).Value = SLD00OB.Caption
If SLD1OB = True Then
Cells(emptyRow, 2).Value = SLD1OB.Caption
If SLD2OB = True Then
Cells(emptyRow, 2).Value = SLD2OB.Caption
End Sub
先谢谢了!
答案 0 :(得分:0)
Dim a As String
For i = 3 To emptyRow
FailureComBox.AddItem a
a = Sheets("StopFel").Cells(i, "D")
Next i
这为我修好了。显然.AddItem
将单元格直接设置为其值存在问题。