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

[µo°Ý] ComboBox©Ô¤U¿ï¶µ°ÝÃD

[µo°Ý] ComboBox©Ô¤U¿ï¶µ°ÝÃD

§Ú¬Oªì¾Çªº, ©Ò¥H§Ú°Ñ¦Ò³o¸Ì¤j¤jªº©«¤l, §Ú°Ñ¦Ò¤F¥H¤Uªºµ{¦¡, ¦ý·Qª¾¹D¬°¤°»ò­n¥Î For...Next?

Private Sub UserForm_Activate()
                     
             Dim MyArray As Variant
            Dim Ctr As Integer
            MyArray = Array("1A", "2B", "3A")
            For Ctr = LBound(MyArray) To UBound(MyArray)
            UserForm2.ComboBox1.AddItem MyArray(Ctr)
     Next


     
            End Sub

¥»©«³Ì«á¥Ñ GBKEE ©ó 2014-8-5 09:17 ½s¿è

¦^´_ 1# patrickccs
LBound,UBound µ¥¨ç¼Æ¥i¨ìVBAµøµ¡ªº»¡©ú¬Ý¬Ý¤F¸Ñ¤@¤U¥Îªk

LBound(MyArray),¶Ç¦^MyArray³o°}¦C¤¸¯Àªº¤U­­¯Á¤Þ­È =0
UBound(MyArray),¶Ç¦^MyArray³o°}¦C¤¸¯Àªº¤W­­¯Á¤Þ­È=2
For Ctr ³o°j°é, ·|±q 0 ªº 2 ¨Ì§Ç¶Ç¦^
MyArray(0)="1A", MyArray(1)="2B", MyArray(2)="3A"
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 2# GBKEE ©ú¥Õ, ÁÂÁ¸ѵª, §Y¬O»¡, ¦bMyArray¸Ì, §Ú¼W¥[¦h¤@¨Ç, 4A, 5Aµ¥µ¥, UBound´N·|ÀHµÛMyArray¦³¦h¤Ö¶µ¦Ó¼W¥[, ¹ï¶Ü?

¥t¥~, ¦pªGComboBoxªº¿ï¶µ¸ê®Æ§Ú¤£·Q¦Û¤v³]©w, ¦Ó¬O±qexcelªíÄæA¤¤©Ò¨ú±o, ¨º§ÚÀ³¸Ó±q­þ­Ó¤è¦V¾Ç, ­n¥Î­þ¤@­Ócommand©O?

·PÁÂ!!!

TOP

¦^´_ 3# patrickccs
¦A¦h¬Ý¬Ý°Q½×°Ïªº¦^ÂФå,¹ïvbaªº¥Îªk¥i¥H¦h¤F¸Ñ£¸¨Ç.
  1. Private Sub UserForm_Initialize() 'ªí³æªì©l¤Æ(¥¼Åã¥Ü«e)ªº¹w³]µ{¦¡
  2.     ComboBox1.List = Sheets(1).[a1:a15].Value  '«ü©w½d³ò
  3. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : ¡i¬°µ½Ävª§¡j¤H¥Í­n¬°µ½Ävª§¡A¤À¬í¥²ª§¡C
ªð¦^¦Cªí ¤W¤@¥DÃD