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

[µo°Ý] ¦p¦ó¥[¸ê®Æ

[µo°Ý] ¦p¦ó¥[¸ê®Æ

½Ð°Ý¤j¤j¦³¤èªk¥i¥H¦b¦P¤@¦a¤è§âA,B,C,D ¤@¼Ë¸ê®ÆªºE¥[°_¨Ó¶Ü?

BOOK1.rar (7.42 KB)

50 ¦r¸`¥H¤º
¤£¤ä«ù¦Û©w¸q Discuz! ¥N½X

¦^´_ 2# Hsieh


    ÁÂÁ½׾Â,ÁÂÁ«e½ú
«á¾ÇÂǦ¹©«¾Ç²ß¨ìJOIN() Àx¦s®æ­È»Ý­n¸g¹L¨â¦¸Âà¸m,ÅýÅܦ¨¤@ºû°}¦C,¤~¯à³s±µ¦¨·s¦r¦ê
¾Ç²ß¤ß±o¦p¤U,½Ð«e½ú¦A«ü±Ð

Option Explicit
Sub Ex()
Dim A As Range, d, d1, mystr$
'¡ô«Å§iÅܼÆ:A¬O Àx¦s®æÅܼÆ,(d,d1)¬O³q¥Î«¬ÅܼÆ,mystr¬O¦r¦êÅܼÆ
Set d = CreateObject("Scripting.Dictionary")
'¡ô¥Od³o³q¥ÎÅܼƬO ¦r¨å
Set d1 = CreateObject("Scripting.Dictionary")
'¡ô¥Od1³o³q¥ÎÅܼƬO ¦r¨å
For Each A In Range([A1], [A1].End(xlDown))
'¡ô³]³v¶µ°j°é!¥OA³oÀx¦s®æÅܼƬO ½d³òÀx¦s®æ¸Ìªº¤@®æ,
'½d³òÀx¦s®æ:¥»ªí[A1]¨ì [A]©¹¤U§ä³Ì«á¤@­Ó¦³¤º®eÀx¦s®æ,³o½d³òÀx¦s®æ

mystr = Join(Application.Transpose(Application.Transpose(A.Resize(, 4))), ",")
'¡ô¥Omystr³o¦r¦êÅܼƬO AÅܼÆ(Àx¦s®æ)¦V¥kÂX®i4ÄæÀx¦s®æ¸g2¦¸Âà¸m«á,
'¥H ","³s±µ¦¨ªº·s¦r¦ê

d(mystr) = d(mystr) + A.Offset(, 4).Value
'¡ô¥O¥HmystrÅܼƬ°key,item¬O item¦Û¨­ + AÅܼƦV¥k°¾²¾4®æÀx¦s®æ(EÄæ)­È,
'¯Ç¤Jd¦r¨å

d1(mystr) = Array(A.Value, A.Offset(, 1).Value, A.Offset(, 2).Value, _
            A.Offset(, 3).Value, d(mystr))
'¡ô¥O¥HmystrÅܼƬ°key,item¬O °}¦C(AÅܼÆ(§t)¥k°¼4­ÓÀx¦s®æ­È,
'¥HmystrÅܼƬdd¦r¨åªºitem­È)

Next
[H:L] = ""
'¡ô¥O[H:L]Àx¦s®æ­È¬O ªÅ¦r¤¸
[H1].Resize(d1.Count, 5) = Application.Transpose(Application.Transpose(d1.items))
'¡ô¥O[H1]ÂX®i¦V¤Ud1¦r¨åkey¼Æ¦C,ÂX®i¦V¥k5Äæ,³o½d³òÀx¦s®æ­È¥Hd1¦r¨åitemsÂà¸m¨â¦¸±a¤J
End Sub
¥Î¦æ°Ê¸Ë¸mÂsÄý½×¾Â¾Ç²ß«Ü¤è«K,ÁÂÁ½׾¸gÀç¹Î¶¤
½Ð¤j®a¤@°_¤W½×¾Â¨Ó¥æ¬y

TOP

¦^´_ 29# b9208


    §Ú¬O«á¾Ç, ½×¾Â¤W½Íªº³£¬O§Ú¶i¨BªºÂ³­¹,·|«Ü¬Ã±¤ªº,³o­Ó½×¾Â¯uªºÀ°§U§Ú«Ü¦h,­É¦¹¦A»¡ÁnÁÂÁ¤j®a!!:D
V98

TOP

linshin1999 ¥S

©ó#18¹ïtranspos»¡©ú«D±`¸Ô²Ó
«Øij¹ïtransposÅܤƤ£¤F¸Ñªº¡A¥i¥H«e©¹«ôŪ¡C
«D±`·PÁÂ
100 ¦r¸`¥H¤º
¤£¤ä«ù¦Û©w¸q Discuz! ¥N½X

TOP

«ç»òÁ¿©O?´N¬O¤@ÂIÂI¥[¤@ÂIÂI¥[,µM«á´NÀ´¤F,ÁÂÁ¦U¦ì,©ñ°²¤F¤j®a³£ÁÙ¦b§V¤O,FAlonso¥xÆW¦n§N,¨º¸ÌÁÙ¦n§a!
V98

TOP

¦^´_ 26# Hsieh
¦hÁÂH¤j«üÂI,²{¦b²×©ó§¹¥þ¸Ñ³q¤F
¥t¥~¦b#18,§Ú·s¼W¤F¤@¨Çµ§°O,§Æ±æ¥H«á¹ï¥L¤H¦³¥Î
80 ¦r¸`¥H¤º
¤£¤ä«ù¦Û©w¸q Discuz! ¥N½X

TOP

¦^´_ 25# linshin1999
dim d as object
³o¬O¥¿½T«Å§i¡Adictionary¥L¬O­Óª«¥ó©Ò¥H«Å§i¬°ª«¥ó¨S¿ù
dictionary³o­Óª«¥ó¤£·|¦]¬°¥Lªºkey»Pitem²£¥Í¸ê®Æ«¬ºAÅܤÆ
§A¥i±N¦¹ª«¥ó¬Ý¦¨¤@­Ó®e¾¹¡A¦¹®e¾¹ªº¤º®eª«¨Ã¤£·|§ïÅܦ¹®e¾¹¥»¨­ªº©Ê½è

©Ò¥HVBA»¡©ú¤¤´£¨ì
dictionaryª«¥ó¡A¨äkey¦¡°£¤F°}¦C¥H¥~ªº¥ô¦ó¸ê®Æ«¬ºA¡A¦Óitem«h¥i¬°¥ô¦ó§ÎºAªº¸ê®Æ¡C
¤@­ÓÃöÁä¦r¥i¹ïÀ³¥ô¦óªº¸ê®Æ¡A³o¬O¦¹ª«¥óªº¯S©Ê¡C
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¥»©«³Ì«á¥Ñ linshin1999 ©ó 2011-1-8 11:26 ½s¿è

¦^´_ 16# basarasy

Åܼƭn¥ÎObject¶Ü?
Dim d as Object ??



Dim d                                                              '«Ø¥ß¤@­ÓÅܼÆ
Set d = CreateObject(Scripting.Dictionary)


VBA ¤¤Åܼƪº«Å§i¤£©ú½T»¡©ú«¬§O¬°¦ó®É,¥¦ªº«¬§O´N¬O Variant ¥¦ªº·N«ä´N¬O¤°»ò«¬ºA³£¥i¥H,
1)¦³¦n³B:´N Scripting.Dictionary ¨ÓÁ¿,¥¦­n³BÍù¸òµÛ¨Óªº °}¦C ©Ò¥H¥¦ªº«¬§O·|¸òµÛ«á­±ªº °}¦C ¶],¥¦ªº«¬§O´N¤@©w­n¬O Variant ,¦pªG没¦³ variant ³o­Ó«¬§O, Dictionary ´N¤£¦s¦b¤F .
2)¦³¯ÊÂI:´N¬O¤£©ú½T,¹ï©ó²ßºD©ú½T«¬§Oªº¤H·|«Ü¤£²ßºD,§Ú¤]¬O³o¼Ë.

¤µ¤Ñ¦A¦^ÀYŪ Hsieh ª©¥D ©M TAlonso ºë±mªº½×­z,¤~ª`·N¨ì¦³³o«h¦^´_,¯u¤£¦n·N«ä.


¦^´_ 24# b9208

¤Óºë±m¤F,§Ú¤]¨Ó¥[½X.
V98

TOP

·PÁ¦U¦ì¥ý¶i
¤§«e°w¹ïdictionary & transpose Á`¬O¤£¤Ó¤F¸Ñ
¬Ý§¹¥»¤å³¹«á¡AÁ`ºâ¤ñ¸û¤F¸Ñ¨ä¥Îªk¤F¡C
100 ¦r¸`¥H¤º
¤£¤ä«ù¦Û©w¸q Discuz! ¥N½X

TOP

Dictionaryª«¥ó·í¥[¤JKEYªº¦P®É§Y²£¥Í¹ïÀ³¸ÓKEYªº­È¬°Emptyªºªì©l­È
¾ã­Óª«¥ó·í¥iµø¬°¤Gºû°}¦C
¨ä²Ä¤@ºû«h¬O¸Óª«¥óªº¼Æ¶q
¨ä²Ä¤Gºû«h¬O¸Óª«¥óªºkeys»Pitems
¸Ó°}¦C¤j¤pªí¥Ü¦p¤U:
ThisArray(d.count,2)
¦ý§AµLªk¥HINDEX«ü©w¸Ó°}¦C
¦]¬°³o¥u¬O±N¨äµø¬°¤Gºû°}¦C
¦ý¹ê»Ú¤W¥L¬O2­ÓÁa¦Cªº°}¦C¦X°_¨Ó
©Ò¥H¤@¯ëÀ³¥Î¤W·|¥H¨äKeyª½±µ«ü©w¨ì¹ïÀ³ªºItem
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

        ÀR«ä¦Û¦b : ¤Ñ¤W³Ì¬ü¬O¬P¬P¡A¤H¥Í³Ì¬ü¬O·Å±¡¡C
ªð¦^¦Cªí ¤W¤@¥DÃD