- 帖子
- 60
- 主題
- 4
- 精華
- 0
- 積分
- 64
- 點名
- 0
- 作業系統
- w7-32
- 軟體版本
- 2013.2003
- 閱讀權限
- 20
- 註冊時間
- 2014-11-23
- 最後登錄
- 2016-6-6
|
2#
發表於 2015-9-27 10:49
| 只看該作者
補充
清單的載入是從另一個Sheets- Private Sub ComboBox1_Change()
- If Me.ComboBox1.ListIndex > 0 Then
- Me.ListBox1.Visible = True
- i = Me.ComboBox1.ListIndex
- Sheets("駕駛").Select
- X = Cells(65536, i + 1).End(xlUp).Row
- ListBox1.Height = 20 * X
- UserForm.Height = 15 * X + 60
- ListBox1.Clear
- For Each xR In Range(Cells(2, i + 1), Cells(X, i + 1))
- ListBox1.AddItem xR.Value
- Next
- ListBox1.ListIndex = 0
- Sheets(1).Select
- End If
- End Sub
- Private Sub ListBox1_Click()
- Sheets(1).Select
- Cells.Interior.ColorIndex = xlNone
- For j = 1 To ListBox1.ListCount - 1
- If ListBox1.Selected(j) = True Then
- gx = ListBox1.Value
- Set cx = Sheets(1).Cells.Find(gx, after:=[A1])
- If cx Is Nothing Then
- ActiveCell = ListBox1.Value
- If ActiveCell.Column = 1 Then
- ActiveCell.Offset(1, 0).Select
- Else
- ActiveCell.Offset(0, -1).Select
- End If
- Else
- cx.Interior.ColorIndex = 3
- MsgBox "名單重複加入" & cx.Address
- End If
- End If
- Next
- End Sub
- Private Sub UserForm_Initialize()
- Me.ListBox1.Visible = False
- Rx = Sheets("駕駛").[A65536].End(xlUp).Row
- Me.ComboBox1.List = Sheets("駕駛").Range("A2:A" & Rx).Value
- Me.ComboBox1.ListRows = Rx
- Me.ComboBox1 = "班別"
- UserForm.Height = 57
- End Sub
- Private Sub ComboBox1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
- ComboBox1.DropDown
- Me.ListBox1.Visible = False
- Me.ComboBox1 = "班別"
- UserForm.Height = 57
- End Sub
複製代碼 |
|