2016-10-14 48 views
0

選擇什麼自己在這裏的最後一個問題繼續 - Excel combobox dropdown items based on the previous combobox自動計數條目的數量取決於ComboBox1

我加4文本框的CRIS,TRACS,文檔和TOTAL。 我想有填充上我在ComboBox1選擇什麼樣的選擇depeding上可見的計數器Tracker

Private Sub cmdBack_Click() 

Unload Me 
frmLogin.Show 

End Sub 

Private Sub cmdClear_Click() 
Call UserForm_Initialize 
End Sub 

Private Sub cmdMove_Click() 

Dim emptyRow As Long 

Sheet1.Activate  'Make Sheet1 active 

emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1  'Determine emptyRow 

'Transfer information 
Cells(emptyRow, 1).Value = txtName.Value 
Cells(emptyRow, 2).Value = txtBtn.Value 
Cells(emptyRow, 3).Value = txtCbr.Value 
Cells(emptyRow, 4).Value = txtOrder.Value 
Cells(emptyRow, 5).Value = txtTrouble.Value 
Cells(emptyRow, 6).Value = ComboBox1.Value 
Cells(emptyRow, 7).Value = ComboBox2.Value 

End Sub 

Private Sub ComboBox1_Change() 
Select Case ComboBox1.Text 
    Case "TRACS" 
     With ComboBox2 
      .Clear 
      .AddItem "Complete" 
      .AddItem "Re-Route" 
     End With 
    Case "CRIS" 
     With ComboBox2 
      .Clear 
      .AddItem "Close" 
      .AddItem "Re-route" 
      .AddItem "Transfer" 
     End With 

    Case "DOCS" 
     With ComboBox2 
      .Clear 
      .AddItem "Completed" 
      .AddItem "Follow-up" 
      .AddItem "Reject" 
     End With 
End Select 
End Sub 

Private Sub UserForm_Click() 

End Sub 

Private Sub UserForm_Initialize() 

txtName.Value = ""   'Empty NameTextBox 
txtBtn.Value = ""   'Empty BTN 
txtCbr.Value = ""   'Empty CBR 
txtOrder.Value = ""   'Empty Order Number 
txtTrouble.Value = ""  'Empty Trouble Ticket Number 

ComboBox1.Clear 
ComboBox2.Clear 

With ComboBox1 
    .AddItem "CRIS" 
    .AddItem "TRACS" 
    .AddItem "DOCS" 
End With 

txtName.SetFocus 

End Sub 

回答

0

我會做的事情有點不同:托馬斯Inzina

Private Sub cmdBack_Click() 
    Unload Me 
    frmLogin.Show 
End Sub 

Private Sub cmdClear_Click() 
    txtName.Value = ""   'Empty NameTextBox 
    txtBtn.Value = ""   'Empty BTN 
    txtCbr.Value = ""   'Empty CBR 
    txtOrder.Value = ""   'Empty Order Number 
    txtTrouble.Value = ""  'Empty Trouble Ticket Number 
    ComboBox2.Clear 
    ComboBox1.ListIndex = -1 
    txtName.SetFocus 
End Sub 

Private Sub cmdMove_Click() 
    With Sheet1 
     With .Range("A" & .Rows.Count).End(xlUp) 
      .Offset(1).Resize(1, 7).Value = Array(txtName.Value, txtBtn.Value, txtCbr.Value, txtOrder.Value, txtTrouble.Value, ComboBox1.Value, ComboBox2.Value) 
     End With 

     txtCRIS.Value = Application.CountIf(.Columns(6), "CRIS") 
     txtTRACS.Value = Application.CountIf(.Columns(6), "TRACS") 
     txtDOCS.Value = Application.CountIf(.Columns(6), "DOCS") 
     txtTotal.Value = Application.Sum(txtCRIS.Value, txtTRACS.Value, txtDOCS.Value) 

    End With 
End Sub 

Private Sub ComboBox1_Change() 
    Select Case ComboBox1.Text 
    Case "TRACS" 
     ComboBox2.List = Array("Complete", "Re-Route") 
    Case "CRIS" 
     ComboBox2.List = Array("Close", "Re-route", "Transfer") 
    Case "DOCS" 
     ComboBox2.List = Array("Completed", "Follow-up", "Reject") 
    End Select 
End Sub 

Private Sub UserForm_Initialize() 
    ComboBox1.List = Array("CRIS", "TRACS", "DOCS") 
    txtName.SetFocus 
End Sub 
+0

喜先生,謝謝你這麼多你的快速反應,是的,它絕對適合我。它現在很重要。我必須一行一行地完全理解代碼,這是我的下一個優先事項。我也想重置櫃檯,因爲這是每天都有的。我會在我的追蹤器中添加一個日期字段。所以第二天它會回到零。再次非常感謝你。 – Zhamepace

+0

不客氣。感謝您接受我的回答。 –