ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ListBox1.ColumnCount = 2®É,¦p¦óAddItem?¦p¦ó¨ú¥X?

[µo°Ý] ListBox1.ColumnCount = 2®É,¦p¦óAddItem?¦p¦ó¨ú¥X?

½Ð±Ð¦U¦ì¤j¤j
     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
°ÝÃD¬O:
1.AddItem®É   ¦p¦ó¨Ï    ListBox1.List (column(1) )= d.Keys  ¦Ó  column(2) AddItem¬O  d.Items
          ListBox1.List= d.Keys  ¶È¬Ocolumn(1)
2 ·í  ListBox1_Click()
   ¦p¦ó¨Ï        TextBox1 = ListBox1.Value(²Ä¤@­Ócolumn)
                       TextBox2= ListBox1.Value(²Ä¤G­Ócolumn)
Àµ½Ð«ü¾É    ÁÂÁÂ

¥»©«³Ì«á¥Ñ GBKEE ©ó 2014-12-7 08:01 ½s¿è

¦^´_ 1# yangjie
  1. Option Explicit
  2. Private Sub UserForm_Initialize()
  3.     Dim d As Object, a As Integer, i As Long
  4.    ' Set d = CreateObject("Scripting.Dictionary")
  5.     ListBox1.ColumnCount = 2
  6.     With Sheets("°ò¥»¸ê®Æ")
  7.          .Visible = True
  8.         For i = 1 To .Cells(65536, 4).End(xlUp).Row
  9.             ListBox1.AddItem
  10.             a = ListBox1.ListCount - 1
  11.             ListBox1.List(a, 0) = .Cells(i, 4)
  12.             ListBox1.List(a, 1) = .Cells(i, 5)
  13.         Next
  14.     End With
  15.    ' a = d.Keys
  16.    ' b = d.Items
  17. End Sub
  18. Private Sub ListBox1_Click()
  19.     Dim a As Integer
  20.     a = ListBox1.ListIndex
  21.     TextBox1 = ListBox1.List(a, 0)
  22.     TextBox2 = ListBox1.List(a, 1)
  23. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¥»©«³Ì«á¥Ñ yangjie ©ó 2014-12-8 15:22 ½s¿è

¦^´_ 2# GBKEE
ÁÂÁÂ
¤£¥ÎDictionary ¦Ó¹F¨ì¥Øªº¡A§Ú¨ü±Ð¤F¡C
For i = 1 To .Cells(65536, 4).End(xlUp).Row
            ListBox1.AddItem
            a = ListBox1.ListCount - 1  
            ListBox1.List(a, 0) = .Cells(i, 4)
            ListBox1.List(a, 1) = .Cells(i, 5)
Next
¨ä¤¤
a = ListBox1.ListCount - 1  ¥i¯à±o¨ì -1­È
¦p¦óÁקK?

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2014-12-8 16:22 ½s¿è

¦^´_ 3# yangjie
ListBox1.ListCount= -1
ªí¥Ü ListBox1.List¬OªÅªº°}¦C
  1. ListBox1.AddItem
  2. '¦³AddItem: ListBox1.ListCount¤£·|¬O -1
  3. a = ListBox1.ListCount - 1
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 2# GBKEE
½Ð±ÐGBKEEª©¤j
¦]listbox1¥Îadditem¼W¥[item¦Ó¤£¬O¥Î.referto§@list
(¦]¬°¸ê®Æ¨Ó·½¦³¿ï¾Ü©Ê(¥i¯à¬O²Ä3,4,8,12,13,14,18.....¦C)
¬G¦p¦ó³]©w©Î¥O¨Ï²Ä¤@¦Clistitem¤£°Ê,(scrollbarsÂà°Ê®É)
¤]´N¬O»¡±N²Ä¤@¦C³]©w¬°¼ÐÀYcolumnheads(©ÎÃþ¦ü)
·q½Ð«ü¾É  ÁÂÁÂ

TOP

¦^´_ 5# yangjie

(¦]¬°¸ê®Æ¨Ó·½¦³¿ï¾Ü©Ê(¥i¯à¬O²Ä3,4,8,12,13,14,18.....¦C)
§AµLªk±N¤£³sÄòªºRange«ü©wµ¹RowSource

¥iÂà­ÓÅs, ¦b(additem)®É¦b«ü©wªºRange("xxx")±N¸ê®Æ½Æ»s¤U¥h
ListBox1.RowSource = Range("xxx").Address
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¥»©«³Ì«á¥Ñ yangjie ©ó 2014-12-24 17:31 ½s¿è

¦^´_ 6# GBKEE
ÁÂÁÂGBKEEª©¤j
ListBox2.Clear
    wb1.Activate
    With Sheets("·s¥Í¸ê®Æ")
        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
'­n¥[¤J.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
°»¿ù»¡:¨S¦³¦¹¦¨­û©Î....µLªk¥[¤J ©Î²¾°£³¡¤À
¥t¦³¤@°ÝÃD  ·íListBox2_Click
MsgBox ListBox2.List(ListIndex, 3)
MsgBox ListBox2.List(ListIndex, ?)¦p¦ó¥i§ä¥X¸Ó¦Cªº Row?

TOP

¦^´_ 7# yangjie
ListBox2.List(ListIndex, ?)¦p¦ó¥i§ä¥X¸Ó¦Cªº Row?
³o ? À³¸Ó¬OÄæ, Row= ListIndex + 1
  1. 'ListBox2.Clear 'RowSourceµ¹¦ì¸m«á³o.Clear·|¦³¿ù»~
  2.     ListBox2.RowSource = ""
  3.     wb1.Activate
  4.     With Sheets("·s¥Í¸ê®Æ")
  5.         If TextBox11 = 0 Then
  6.             row1 = .Cells(65536, 5).End(xlUp).Row
  7.             If row1 < 2 Then Exit Sub
  8.             Dim MYSTR As String
  9.             With Application.Names.Add("Tmp", .Range(.Cells(2, 1), .Cells(row1 - 5, 11)))
  10.                 MYSTR = .RefersTo
  11.                 .Delete
  12.             End With
  13.             With ListBox2
  14.                 .ColumnCount = 11
  15.                 .RowSource = MYSTR
  16.                 .ColumnHeads = True
  17.             End With
  18.             ListBox2.RowSource = .Range(.Cells(row1 - 1, 1), .Cells(row1 - 1, 11))
  19.          End If
  20.       End With
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : ¦³¤ß´N¦³ºÖ¡A¦³Ä@´N¦³¤O¡A¦Û³yºÖ¥Ð¡A¦Û±oºÖ½t¡C
ªð¦^¦Cªí ¤W¤@¥DÃD