標題: [發問] With .ComboBox2為何沒反應呢??? [打印本頁] 作者: sillykin 時間: 2017-4-5 22:51 標題: With .ComboBox2為何沒反應呢???
本帖最後由 sillykin 於 2017-4-5 22:55 編輯
Dim ColNr As Integer
Dim Arr() As String
Private Sub CommandButton4_Click()
Dim MaxColNr As Integer
With Sheet4
MaxColNr = .Cells(50, .Columns.Count).End(xlShiftToLeft).Column
End With
If ColNr = MaxColNr Then
With .ComboBox2
For i = 0 To .ListCount - 1
If Left(Arr(i), 1) = Sheet4.Cells(53, ColNr) Then
.ListIndex = i
Exit For
End If
Next i
End With
With .ComboBox3
For i = 0 To .ListCount - 1
If Left(Arr(i), 2) = Sheet4.Cells(54, ColNr) Then
.ListIndex = i
Exit For
End If
Next i
End With
End With
End If
End Sub
Private Sub CommandButton5_Click()
If ColNr = 2 Then
MsgBox "這已經是第一個記錄!"
Else
ColNr = ColNr - 1
With UserForm12
With .ComboBox2
For i = 0 To .ListCount - 1
If Left(Arr(i), 1) = Sheet4.Cells(53, ColNr) Then
.ListIndex = i
Exit For
End If
Next i
End With
With .ComboBox3
For i = 0 To .ListCount - 1
If Left(Arr(i), 2) = Sheet4.Cells(54, ColNr) Then
.ListIndex = i
Exit For
End If
Next i
End With
End With
End If
End Sub
ReDim Arr(.ListCount - 1)
For i = 0 To .ListCount - 1
Arr(i) = .List(i)
Next i
For i = 0 To .ListCount - 1
If Left(Arr(i), 1) = Sheet4.Cells(53, ColNr) Then
.ListIndex = i
Exit For
End If
Next i
End With
ReDim Arr(.ListCount - 1)
For i = 0 To .ListCount - 1
Arr(i) = .List(i)
Next i
For i = 0 To .ListCount - 1
If Left(Arr(i), 2) = Sheet4.Cells(54, ColNr) Then
.ListIndex = i
Exit For
End If
Next i
End With