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

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

¥»©«³Ì«á¥Ñ 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

¥»©«³Ì«á¥Ñ 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

¦^´_ 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

¦^´_ 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 : ¦³®É·í«äµL®É­W¡A¦n¤Ñ­n¿n«B¨Ó³¡C
ªð¦^¦Cªí ¤W¤@¥DÃD