我试图弄清楚如何创建具有2列的Depandant组合框。 这是我现在拥有的宏:
Option Explicit
Dim DICT As Object
End Sub
Private Sub UserForm_Initialize()
Dim Analyst As String
Analyst = Sheets("Function_Reference").Range("b11")
'Get Analyst Name, from a hidden reference sheet.
Dim KEY As Variant
Set DICT = CreateObject("Scripting.dictionary")
For Each KEY In [Accounts].Columns(4).Rows
'The analyst name is in column 4, so I adjusted the offset accordingly.
If Not DICT.Exists(KEY.Value) Then
Set DICT(KEY.Value) = CreateObject("scripting.dictionary")
End If
DICT(KEY.Value)(KEY.Offset(, -3).Value) = ""
' offset -3 because account number is on column 1
Next KEY
If Analyst <> "All" then
Me.ComboBox1.List = DICT(Analyst).Keys
Else
Me.ComboBox1.List = [Accounts].Columns("A:B")
End If
'Load the userform with the correct list immedietly.
End Sub
组合框有2列,但只有1列。第1列是客户,第2列是供应商。不同供应商的帐号可以相同,因此没有真实的密钥列,而是必须将两者一起使用,即“帐户供应商”,但出于报告目的,必须将其保留在单独的单元格中。只给你的我如何使用它,当窗体完成一个想法我有:
Private Sub Accept_Click()
[Invoices].Rows(x).Columns(c) = Me.ComboBox1.value
[Invoices].Rows(x).Columns(c+1) = Me.ComboBox1.column(1)
End Sub
从同一组合框拉动两个帐户号码和供应商名称,以两种不同的细胞。
我怎样才能根据分析师的名字过滤此组合框?这样它只会列出其中字符串Analyst = X
的行提前谢谢!