2012-10-18 57 views
0

我如何添加項目和指標組合框,我有以下,但它說,這是一個無效參數:在Excel中添加值+ INDEX對ActiveX組合框用VBA

Me.lstDataSet.AddItem wsB.Range("B5"), wsB.Range("A5") 

A5是整數(索引)值[34],B5是字符串/日期(實際)值[2012年1月4日]。作爲參考,在此之前從數據庫中導入上次更新/插入記錄的代碼。

我想實現的是讓組合框顯示[001 |字符串值],即顯示兩列,我可以稍後參考。

回答

0

將項目添加到第二列,使用.List

Me.ComboBox1.Clear 
Me.ComboBox1.AddItem "1" 
Me.ComboBox1.List(0, 1) = "testing" ' add text in second column (0 based array) 
Me.ComboBox1.AddItem "2342" 
Me.ComboBox1.List(Me.ComboBox1.ListCount-1, 1) = "more testing" 
' add it to last item added, no need to remember where you are