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

vba listbox ColumnHeadsªºªíÀY

vba listbox ColumnHeadsªºªíÀY

¶Ù¡A¤j®a±ß¦w :

·Q½Ð±Ð¤@¤UVBAªí³æ¸Ìªºlistbox¡A¤Á³Î¦nÄæ¦ì«á¡A«ç»ò·s¼WªíÀYªº¤å¦r¤W¥h¡A¦p¤U¹Ï¡A

Google¤@¨Ç¤å³¹¡A³£¨S¦³¬Ý¨ì¦X¾Aªº¡A¯S¨Ó½Ð±Ð¤j®a¡AÁÂÁÂ


    ___

¦^´_ 1# owenchen0911
listbox¡A¤Á³Î¦nÄæ¦ì«á???

ListBox ­nÅã¥ÜColumnHeads,²M³æªº¨Ó·½¥²»Ý¥Î.RowSource «ü©w
RowSource »Ý¬O³æ¤@ªº³sÄòÀx¦s®æ½d³ò ,¤£¥i¥Î¤Á³Î
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_  owenchen0911
listbox¡A¤Á³Î¦nÄæ¦ì«á???

ListBox ­nÅã¥ÜColumnHeads,²M³æªº¨Ó·½¥²»Ý¥Î.RowSour ...
GBKEE µoªí©ó 2016-6-2 07:57



    Hi,

§Úªºcode¦p¤U¡A³o¼Ë¤l¤l¶µ¥Ø¥i¥H¥[¶i¥h¡A¨º»òÀYÁÙ¥i¥H¥Î  "ColumnHeads"¶Ü??ÁÂÁÂ
  1. ListBox1.ColumnCount = 7
  2. ListBox1.ColumnHeads = True

  3. '¼W¥[¶µ¥Ø¶i¥h
  4. IListRow = ListBox1.ListCount
  5.         ListBox1.AddItem ComboBox_drink_name
  6.         
  7.         ListBox1.List(IListRow, 1) = priceArray(ComboBox_drink_name.ListIndex)
  8.         ListBox1.List(IListRow, 2) = ComboBox_number
  9.         ListBox1.List(IListRow, 3) = ComboBox_number * priceArray(ComboBox_drink_name.ListIndex)
  10.         ListBox1.List(IListRow, 4) = ComboBox_ice
  11.         ListBox1.List(IListRow, 5) = ComboBox_sugar
  12.         ListBox1.List(IListRow, 6) = ComboBox_takeout
  13.         
  14.         xItemCount = xItemCount + 1
½Æ»s¥N½X

TOP

¦^´_ 3# owenchen0911
¸Õ¸Õ¬Ý
  1. Option Explicit
  2. Dim Sh As Worksheet
  3. Private Sub UserForm_Initialize()
  4.     Dim Rng As Range
  5.     Set Sh = ActiveSheet   '«ü©wListBox1.RowSource ªº¤u§@ªí
  6.     Set Rng = Sh.Range("A1").CurrentRegion
  7.    
  8.     'CurrentRegion ÄÝ©Ê ¶Ç¦^ Range ª«¥ó¡A¸Óª«¥ó¥Nªí¥Ø«eªº°Ï°ì¡C¥Ø«e°Ï°ì¬O«ü¥H¥ô·NªÅ¥Õ¦C¤ÎªÅ¥ÕÄ檺²Õ¦X¬°Ãä¬Éªº½d³ò¡C
  9.    
  10.     Set Rng = Application.Intersect(Rng, Rng.Offset(1))
  11.     If Rng Is Nothing Then Set Rng = Sh.Range("A1").CurrentRegion.Rows(2)  '¨S¦³Áʪ«²M³æ
  12.     With ListBox1
  13.         .ColumnHeads = True
  14.         .RowSource = Rng.Address
  15.     End With
  16. End Sub
  17. Private Sub Ex_²M³æ() '¥[¤JÁʪ«²M³æªºµ{¦¡
  18.     Dim Rng As Range
  19.     Set Rng = Sh.Range("A1").CurrentRegion
  20.     With Rng.Cells(Rng.Rows.Count + 1, "A")
  21.         '¼W¥[¶µ¥Ø¶i¥h
  22.        .Cells(1, 1) = priceArray(ComboBox_drink_name.ListIndex)
  23.        .Cells(1, 2) = ComboBox_number
  24.        .Cells(1, 3) = ComboBox_number * priceArray(ComboBox_drink_name.ListIndex)
  25.        .Cells(1, 4) = ComboBox_ice
  26.        .Cells(1, 5) = ComboBox_sugar
  27.        .Cells(1, 6) = ComboBox_takeout
  28.     End With
  29.     Set Rng = Sh.Range("A1").CurrentRegion
  30.     Set Rng = Application.Intersect(Rng, Rng.Offset(1))
  31.     '­«·s«ü©w ListBox1²M³æ½d³ò
  32.     ListBox1.RowSource = Rng.Address
  33. End Sub
  34. Private Sub Ex_²MªÅ() '²MªÅ Áʪ«²M³æªºµ{¦¡
  35.     Sh.Range("A1").CurrentRegion.Offset(1).Clear
  36. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : °µ¦n¨Æ¤£¯à¤Ö§Ú¤@¤H¡A°µÃa¨Æ¤£¯à¦h§Ú¤@¤H¡C
ªð¦^¦Cªí ¤W¤@¥DÃD