請教各位大大
Dim d As Object, a, b
Set d = CreateObject("Scripting.Dictionary")
With .Sheets("基本資料")
.Visible = True
For i = 1 To .Cells(65536, 4).End(xlUp).Row
d(.Cells(i, 4).Text) = .Cells(i, 5)
Next
End With
a = d.Keys
b = d.Items
ListBox1.ColumnCount = 2
問題是:
1.AddItem時 如何使 ListBox1.List (column(1) )= d.Keys 而 column(2) AddItem是 d.Items
ListBox1.List= d.Keys 僅是column(1)
2 當 ListBox1_Click()
如何使 TextBox1 = ListBox1.Value(第一個column)
TextBox2= ListBox1.Value(第二個column)
懇請指導 謝謝作者: GBKEE 時間: 2014-12-7 07:58
回復 6#GBKEE
謝謝GBKEE版大
ListBox2.Clear
wb1.Activate
With Sheets("新生資料")
If TextBox11 = 0 Then
row1 = .Cells(65536, 5).End(xlUp).Row
If row1 < 2 Then Exit Sub
Dim mystr As String
With Application.Names.Add("Tmp", .Range(.Cells(2, 1), .Cells(row1 - 5, 11)))
mystr = .RefersTo
.Delete
End With
With ListBox2
.ColumnCount = 11
.RowSource = mystr
.ColumnHeads = True
End With
'要加入.Range(.Cells(row1 - 1, 1), .Cells(row1 - 1, 11))
With ListBox2
.AddItem
.RowSource = .Range(.Cells(row1 - 1, 1), .Cells(row1 - 1, 11))
End With
End With
偵錯說:沒有此成員或....無法加入 或移除部分
另有一問題 當ListBox2_Click
MsgBox ListBox2.List(ListIndex, 3)
MsgBox ListBox2.List(ListIndex, ?)如何可找出該列的 Row?作者: GBKEE 時間: 2014-12-25 07:07