¡¶excel_vba_±à³Ì½Ì³Ì(ÍêÕû°æ)¡·

ÏÂÔر¾Êé

Ìí¼ÓÊéÇ©

excel_vba_±à³Ì½Ì³Ì(ÍêÕû°æ)- µÚ71½Ú


°´¼üÅÌÉÏ·½Ïò¼ü ¡û »ò ¡ú ¿É¿ìËÙÉÏÏ·­Ò³£¬°´¼üÅÌÉ쵀 Enter ¼ü¿É»Øµ½±¾ÊéĿ¼ҳ£¬°´¼üÅÌÉÏ·½Ïò¼ü ¡ü ¿É»Øµ½±¾Ò³¶¥²¿£¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡ws¡¡As¡¡Worksheet¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Application¡£DisplayAlerts¡¡=¡¡False¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡For¡¡Each¡¡ws¡¡In¡¡Worksheets¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡If¡¡InStr£¨ws¡£Name£»¡¡¡¨wages¡¨£©¡¡Then¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ws¡£Delete¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡If¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Next¡¡¡¡¡¡
¡¡¡¡¡¡¡¡End¡¡Sub¡¡¡¡¡¡
µ±Äã±àдÄã×Ô¼ºµÄVBA¹ý³Ìʱ£¬Äã¿ÉÄÜ»áÅöµ½ÕâÑùÒ»ÖÖÇé¿ö£¬ÄǾÍÊÇ£¬Ã»Óз½±ãµÄÄÚÖü¯ºÏÀ´´¦Àí¡¡
ÄãµÄÈÎÎñ¡£½â¾ö°ì·¨¾ÍÊÇ´´½¨×Ô¶¨Ò弯ºÏ¡£´ÓµÚÆßÕ£¬Äã¾ÍÒѾ­ÖªµÀÈçºÎͨ¹ý¶¯Ì¬»ò¾²Ì¬Êý×éÀ´Êµ¡¡
Óöà¸öÊý¾Ý¡£ÒòΪ£¬¼¯ºÏÓÐÔÊÐíÄãÌí¼Ó¡¢Òƶ¯ºÍ¼ÆËãÆä³ÉÔ±µÄÄÚÖÃÊôÐԺͷ½·¨£¬ËùÒÔʹÓü¯ºÏ±Èʹ¡¡
ÓÃÊý×éÈÝÒ׵öࡣ¡¡¡¡

2¡£ÉùÃ÷×Ô¶¨Ò弯ºÏ¡¡¡¡

Òª´´½¨Ò»¸öÓû§¶¨ÒåµÄ¼¯ºÏµÄ»°£¬ÄãÓ¦¸ÃÏÈÉùÃ÷Ò»¸öCollectionÀàÐ͵ĶÔÏó±äÁ¿£¬¸Ã±äÁ¿ÔÚDimÓï¡¡
¾äÀïºÍ¹Ø¼ü×ÖNewÒ»ÆðÉùÃ÷£¬ÈçÏÂËùʾ£º¡¡¡¡
Dim¡¡¼¯ºÏÃû³Æ¡¡As¡¡New¡¡Collection¡¡¡¡¡¡

3¡£¸ø×Ô¶¨Ò弯ºÏÌí¼Ó¶ÔÏó¡¡¡¡

ÔÚÉùÃ÷Collection¶ÔÏóºó£¬Äã¾Í¿ÉÒÔʹÓÃAdd·½·¨Íù¼¯ºÏÀï²åÈëгÉÔ±ÁË¡£ÓÃÀ´×é³É¸Ã¼¯ºÏµÄ¶ÔÏó¡¡
²»±ØÐèÒªÊÇͬÑùµÄÊý¾ÝÀàÐÍ¡£Add·½·¨ÈçÏÂËùʾ£º¡¡¡¡
object¡£Add¡¡item£»¡¡key£»¡¡before£»¡¡after¡¡¡¡¡¡
ÄãÖ»ÐèÒªÃ÷È·¶ÔÏóºÍ³ÉÔ±£¬objectÊǼ¯ºÏÃû³Æ£¬ËüÊÇʹÓÃÔÚCollection¶ÔÏóÉùÃ÷ÖеÄÏàͬÃû³Æ£»item¡¡
ÊÇÄãÒªÌí¼Óµ½¼¯ºÏÀïµÄ¶ÔÏó¡£¾¡¹ÜÆäËüµÄ²ÎÊýÊÇ¿ÉÑ¡µÄ£¬µ«ÊÇËüÃÇÒ²ºÜÓÐÓ᣼¯ºÏÀïµÄ³ÉÔ±×Ô¶¯´Ó¡¡
1¿ªÊ¼·ÖÅäºÅÂ룬Á˽âÕâ¸öºÜÖØÒª¡£È»¶ø£¬ËüÃÇÒ²¿ÉÒÔ¸ø·ÖÅäÒ»¸ö¶ÀÌصļü¡£³ýÁËͨ¹ýË÷ÒýºÅ£¨1£¬¡¡
2£¬3µÈµÈ£©·ÃÎÊij¸öÌض¨µÄ³ÉÔ±Ö®Í⣬ÄãÒ²¿ÉÒÔÔÚ¼¯ºÏÌí¼Ó¶ÔÏóµÄʱºò¸ø¸Ã¶ÔÏó·ÖÅäÒ»¸ö¼ü¡£ÀýÈ磬¡¡
Èç¹ûÄã´´½¨Ò»¸ö×Ô¶¨Ò幤×÷±í¼¯ºÏ£¬ÄÇôÄãÓ¦¸ÃʹÓù¤×÷±íÃû³Æ×÷Ϊ¼ü£»Òª¼ø±ðѧÉú»òÕßÔ±¹¤¼¯ºÏ¡¡
ÀïµÄµ¥¸öÈËÔ±µÄ»°£¬Äã¾Í¿ÉÒÔʹÓÃÉç»á±£ÏÕºÅÂ루SSN£©×÷ΪËûÃǵļü¡£¡¡¡¡
Èç¹ûÄãÏëҪȷ¶¨¶ÔÏóÔÚ¼¯ºÏÀïÃæµÄλÖÃʱ£¬ÄÇôÄã¾ÍÓ¦¸ÃʹÓÃbefore»òÕßafter²ÎÊý£¨²»ÒªÍ¬Ê±Ê¹¡¡
ÓÃËüÃÇ£©¡£²ÎÊýbeforeÔÚ´Ë֮ǰÌí¼ÓжÔÏóµÄ¶ÔÏ󣬶ø²ÎÊýafterÊÇÒ»¸ö¶ÔÏó£¬ÔÚËüÖ®ºóÌí¼ÓеĶԡ¡
Ï󡣡¡¡¡
½ÓÏÂÀ´¹ý³ÌGetmentsÉùÃ÷ÁËÒ»¸ö½Ð×öcolNotesµÄ×Ô¶¨Ò弯ºÏ£¬¸Ã¹ý³ÌÌáʾÊäÈë×÷ÕßÐÕÃû£¬È»ºó¡¡
Ôڻ¹¤×÷²¾Àï±éÀúËùÓеŤ×÷±í£¬ÒÔÕÒµ½¸Ã×÷ÕßµÄÅú×¢¡£Ö»ÓÐij¸öÌض¨×÷ÕßÊäÈëµÄÅú×¢»á¼ÓÈë×Ô¡¡
¶¨Ò弯ºÏ¡£¹ý³Ì¸øµÚÒ»¸öÅú×¢·ÖÅäÒ»¸ö¼ü£¬È»ºó½«Ê£ÓàµÄÅú×¢Ìí¼Óµ½¼¯ºÏÀÿ´Î¶¼½«ËüÃÇÖÃÓÚ×î¡¡
ºóÌí¼ÓµÄÅúע֮ǰ£¨×¢Òâbefore²ÎÊýµÄʹÓã©¡£Èç¹û¼¯ºÏÖÁÉÙÓÐÒ»¸öÅú×¢£¬ÄÇô¹ý³Ì»áÔÚÒ»¸öÐÅÏ¢¡¡
¿òÏÔʾÓɲÎÊýkeyÈ·¶¨µÄÅú×¢ÄÚÈÝ¡£×¢Ò⣬²ÎÊýkeyÈçºÎÓÃÀ´ÒýÓü¯ºÏÀïµÄ³ÉÔ±¡£È»ºó£¬¹ý³Ì½«¼¯ºÏ¡¡
ÀïµÄËùÓÐÅú×¢´òÓ¡µ½Á¢¼´´°¿Ú¡£Îı¾º¯Êý£¨MidºÍLen£©ÓÃÀ´½ö»ñÈ¡Åú×¢ÄÚÈÝ£¬¶øÅųý×÷ÕßÐÕÃû¡£½Ó¡¡
×Å£¬·µ»Ø¹¤×÷²¾ÀïµÄÅú×¢ÊýÄ¿ºÍ×Ô¶¨Ò弯ºÏÀïµÄÅú×¢ÊýÄ¿µ½CountÊôÐÔ¡£ÔÚÊÔÑé¹ý³ÌGetments¡¡
֮ǰ£¬ÎÒÃÇÏȵð´ÕÕÒÔϲ½Öè´´½¨Ò»¸ö¹¤×÷²¾£º¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡215¡¡

¡­¡¡Ò³Ãæ¡¡232¡­

1¡£¡¡´ò¿ªÒ»¸öй¤×÷²¾²¢±£´æΪChap11¡£xls¡¡¡¡
2¡£¡¡ÔÚ¹¤×÷±íSheet1µÄÈÎÒâµ¥Ôª¸ñÉϵ¥»÷ÓÒ¼ü£¬²¢´Ó¿ì½Ý²Ëµ¥ÉÏÑ¡Ôñ²åÈëÅú×¢£¬ËæÒâÊäÈëһЩÎı¾¡£¡¡
¡¡¡¡¡¡¡¡ÔÚÅú×¢¿òÖ®ÍâµÄÈÎÒâµØ·½µã»÷һϣ¬Í˳öÅú×¢±à¼­Ä£Ê½¡£Ê¹ÓÃÏàͬµÄ¼¼ÇÉÔÚ¹¤×÷±íSheet2Ôٲ塡
¡¡¡¡¡¡¡¡ÈëÁ½¸öÅú×¢£¬¸øÿ¸öÅú×¢ÊäÈ벻ͬµÄÎı¾¡£ÔÚµ±Ç°¹¤×÷²¾Àï²åÈëй¤×÷±í£¨Sheet4£©£¬²¢²åÈëÒ»¡¡
¡¡¡¡¡¡¡¡¸öÅú×¢¡£ÏÖÔÚÄãÓ¦¸ÃÔÚÈý¸ö¹¤×÷±íÀïÒ»¹²ÓÐËĸöÅú×¢¡£¡¡¡¡
3¡£¡¡Ñ¡Ôñ¡°¹¤¾ß¡±£ü¡°Ñ¡Ï²¢ÇÒµã»÷¡°³£¹æ¡±Ò³£¬Óû§ÃûÎı¾¿òÀïÃæÓ¦¸ÃÏÔʾµÄÊÇÄãµÄÃû×Ö£¬É¾³ý¡¡
¡¡¡¡¡¡¡¡Äã×Ô¼ºµÄÃû×Ö£¬²¢ÊäÈëJoan¡¡Simth£¬²¢µã»÷È·¶¨¡£ÏÖÔÚ£¬ÔÚ¹¤×÷±íSheet2ºÍSheet4µÄÈÎÒâµØ·½¡¡
¡¡¡¡¡¡¡¡¸÷ÊäÈëÒ»¸öÅú×¢¡£ÕâЩÅú×¢Ó¦¸Ã»á×Ô¶¯µØÓ¡ÉÏJoan¡¡SmithµÄÃû×Ö¡£µ±ÄãÊäÈëÍêÅú×¢ºó£¬»Øµ½Ñ¡¡¡
¡¡¡¡¡¡¡¡Ïî¶Ô»°¿ò£¬²¢½«³£¹æÒ³ÉϵÄÓû§Ãû¸Ä»ØÄã×Ô¼ºµÄÃû×Ö¡£¡¡¡¡
4¡£¡¡Çл»µ½VB±à¼­Æ÷£¬²¢½«VBA¹¤³ÌÖØÃüÃûΪObjColClass¡¡¡¡
5¡£¡¡ÔÚµ±Ç°¹¤³ÌÀïÌí¼ÓÒ»ÐÂÄ£¿é£¬²¢ÖØÃüÃûΪMyCollection¡¡¡¡
6¡£¡¡ÊäÈë¹ý³ÌGetments£¬ÏÔʾÈçÏ£º¡¡¡¡
¡¡¡¡¡¡¡¡Sub¡¡Getments£¨£©¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡sht¡¡As¡¡Worksheet¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡colNotes¡¡As¡¡New¡¡Collection¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡myNote¡¡As¡¡ment¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡I¡¡As¡¡Integer¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡t¡¡As¡¡Integer¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡fullName¡¡As¡¡String¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡fullName¡¡=¡¡InputBox£¨¡¨Enter¡¡author's¡¡full¡¡name£º¡¨£©¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡For¡¡Each¡¡sht¡¡In¡¡ThisWorkbook¡£Worksheets¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡sht¡£Select¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡I¡¡=¡¡ActiveSheetmentsunt¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡For¡¡Each¡¡myNote¡¡In¡¡ActiveSheetments¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡If¡¡myNote¡£Author¡¡=¡¡fullName¡¡Then¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡MsgBox¡¡myNote¡£Text¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡If¡¡colNotesunt¡¡=¡¡0¡¡Then¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡colNotes¡£Add¡¡Item£º=myNote£»¡¡key£º=¡¨first¡¨¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Else¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡colNotes¡£Add¡¡Item£º=myNote£»¡¡Before£º=1¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡If¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡If¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Next¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡t¡¡=¡¡t¡¡£«¡¡I¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Next¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡If¡¡colNotesunt¡¡¡¡0¡¡Then¡¡MsgBox¡¡colNotes£¨¡¨first¡¨£©¡£Text¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡MsgBox¡¡¡¨Total¡¡ments¡¡in¡¡workbook£º¡¡¡¨¡¡&¡¡t¡¡&¡¡Chr£¨13£©¡¡&¡¡_¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¨Total¡¡ments¡¡in¡¡collection£º¡¨¡¡&¡¡colNotesunt¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Debug¡£Print¡¡¡¨ments¡¡by¡¡¡¨¡¡&¡¡fullName¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡For¡¡Each¡¡myNote¡¡In¡¡colNotes¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Debug¡£Print¡¡Mid£¨myNote¡£Text£»¡¡Len£¨myNote¡£Author£©¡¡£«¡¡2£»¡¡_¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Len£¨myNote¡£Text£©£©¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Next¡¡¡¡¡¡
¡¡¡¡¡¡End¡¡Sub¡¡¡¡¡¡
7¡£¡¡ÔËÐйý³ÌGetments²¢ÇҲ鿴½á¹û¡¡¡¡

4¡£´Ó×Ô¶¨Ò弯ºÏÒƳö¶ÔÏó¡¡¡¡

´Ó×Ô¶¨Ò弯ºÏÀïÒƳö³ÉÔ±ºÍÌí¼Ó³ÉÔ±Ò»Ñù¼òµ¥¡£Ê¹ÓÃRemove·½·¨¿ÉÒÔÒƳö¶ÔÏó£¬ÈçÏÂËùʾ£º¡¡¡¡
object¡£Remove¡¡item¡¡¡¡
objectÊÇ×Ô¶¨Ò弯ºÏµÄÃû³Æ£¬º¬ÓÐÄãÒªÒƳöµÄ¶ÔÏó£»itemÊÇÄãÒª´Ó¼¯ºÏÒƳöµÄ¶ÔÏ󡣡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡216¡¡

¡­¡¡Ò³Ãæ¡¡233¡­

ÎÒÃÇÀ´ÐÞ¸ÄÄãÔÚÇ°Ã沿·Ö×¼±¸µÄ¹ý³ÌGetments£¬Ê¾·¶´Ó¼¯ºÏÀïÒƳö³ÉÔ±¡£Ôڸùý³Ì½á⣬ÎÒÃÇ¡¡
½«µ±Ç°¼¯ºÏcolNotesÀï³ÉÔ±µÄÄÚÈÝÒ»¸öÒ»¸öµØÏÔʾ³öÀ´£¬²¢ÇÒѯÎÊÓû§£¬Ê¹ÓÃÓ¦¸Ã½«¸Ã³ÉÔ±´Ó¸Ã¼¯¡¡
ºÏÒƳö¡£¡¡¡¡
1¡£¡¡½«ÏÂÃæµÄÉùÃ÷¼ÓÈëµ½¹ý³ÌGetmentsµÄÉùÃ÷²¿·Ö£º¡¡¡¡
¡¡¡¡¡¡¡¡Dim¡¡response¡¡¡¡¡¡
¡¡¡¡¡¡¡¡Dim¡¡myId¡¡As¡¡Integer¡¡¡¡¡¡
¡¡¡¡¡¡¡¡µÚÒ»ÌõÓï¾äÉùÃ÷ÁËÒ»¸ö½Ð×öresponseµÄ±äÁ¿£¬Ä㽫ʹÓøñäÁ¿À´´¢´æMsgboxº¯ÊýµÄ½á¹û¡£µÚ¶þ¡¡
¡¡¡¡¡¡¡¡ÌõÔ¡½íÉùÃ÷±äÁ¿myldÀ´´¢´æ¼¯ºÏ¶ÔÏóµÄË÷ÒýºÅ¡£¡¡¡¡
2¡£¡¡¶¨Î»¹ý³ÌGetmentsµÄÏÂÊöÓï¾ä£º¡¡¡¡
¡¡¡¡¡¡¡¡For¡¡Each¡¡myNote¡¡In¡¡colNotes¡¡¡¡¡¡
¡¡¡¡¡¡¡¡ÔÚÉÏÃæµÄÓï¾äÖ®ºó£¬Ìí¼ÓÏÂÊöÓï¾ä£º¡¡¡¡
¡¡¡¡¡¡¡¡myId¡¡=¡¡1¡¡¡¡¡¡
3¡£¡¡¶¨Î»µ½¹ý³ÌGetmentsµÄÏÂÊöÓï¾ä£º¡¡¡¡
¡¡¡¡¡¡¡¡Debug¡£Print¡¡Mid£¨myNote¡£Text£»¡¡Len£¨myNote¡£Author£©¡¡£«¡¡2£»¡¡_¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡Len£¨myNote¡£Text£©£©¡¡¡¡¡¡
¡¡¡¡¡¡¡¡ÔÚ¸ÃÓï¾äºó£¬ÊäÈëÏÂÃæµÄ´úÂë¿é£º¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡response¡¡=¡¡MsgBox£¨¡¨Remove¡¡this¡¡ment£¿¡¨¡¡&¡¡Chr£¨13£©¡¡_¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡&¡¡Chr£¨13£©¡¡&¡¡myNote¡£Text£»¡¡vbYesNo¡¡£«¡¡vbQuestion£©¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡If¡¡response¡¡=¡¡6¡¡Then¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡colNotes¡£Remove¡¡Index£º=myId¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡Else¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡myId¡¡=¡¡myId¡¡£«¡¡1¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡End¡¡If¡¡¡¡¡¡
4¡£¡¡Ôڸùý³ÌÊäÈëÏÂÊöÓï¾ä£º¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡Debug¡£Print¡¡¡¨The¡¡following¡¡ments¡¡remain¡¡in¡¡the¡¡collection£º¡¨¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡For¡¡Each¡¡myNote¡¡in¡¡colNotes¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Debug¡£Print¡¡Mid£¨myNote¡£Text£»¡¡Len£¨myNote¡£Author£©¡¡£«¡¡2£»¡¡_¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Len£¨myNote¡£Text£©£©¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡Next¡¡¡¡¡¡
5¡£¡¡ÔËÐйý³ÌGetments£¬²¢ÇÒ½«ÏÔʾÔÚÐÅÏ¢¿òÀïÅúע֮һɾ³ý¡£¡¡¡¡
Ð޸ĺóµÄ¹ý³ÌGetments2¿ÉÒÔÔÚ¸½´øµÄCDÀïÕÒµ½¡£¸Ã¹ý³Ì½«Ö¸¶¨µÄÅú×¢´Ó×Ô¶¨Ò弯ºÏÀïÇå³ý£¬µ«¡¡
ÊDz»»á´Ó¹¤×÷±íÀïɾ³ýÅú×¢¡£¡¡¡¡
¼¼ÇÉ11¡­1¡¡¸ø¼¯ºÏÖØбàºÅ¡¡¡¡
µ±ÒƳö¶ÔÏóºó£¬¼¯ºÏ»Ø×Ô¶¯ÖØбàºÅ£¬Òò´Ë£¬Äã¿ÉÒÔʹÓÃ1×÷ΪIndex²ÎÊý£¬À´É¾³ý×Ô¶¨Ò弯ºÏÀïµÄ¡¡
ËùÓжÔÏó£¬ÈçÏÂËùʾ£º¡¡¡¡
Do¡¡While¡¡myCollectionunt¡¡¡·0¡¡¡¡
¡¡¡¡¡¡¡¡myCollection¡£Remove¡¡Index£º=1¡¡¡¡
Loop¡¡¡¡
²åÈ룺ģ¿é»¹ÊÇÀàÄ£¿é£¿¡¡¡¡
ÔÚVB±à¼­Æ÷µÄ²åÈë²Ëµ¥ÀïÓÐÁ½¸öÄ£¿éÃüÁģ¿éºÍÀàÄ£¿é¡£ÕâЩÔÚ±¾ÕµĿªÍ·Óж¨Òå¡£µ½Ä¿Ç°ÎªÖ¹£¬¡¡
ÄãÒѾ­Ê¹Óùý±ê׼ģ¿éÀ´´´½¨SubºÍFunction¹ý³Ì¡£Ä㽫µÚÒ»´ÎÔÚ±¾ÕÂʹÓÃÀàÄ£¿éÀ´´´½¨×Ô¶¨Òå¶Ô¡¡
Ïó²¢ÇÒ¶¨ÒåËüµÄÊôÐԺͷ½·¨¡£¡¡¡¡

5¡£´´½¨×Ô¶¨Òå¶ÔÏó¡¡¡¡

´´½¨Ò»¸öеģ¬·Ç±ê×¼µÄVBA¶ÔÏó£¬ÐèÒªÔÚÄãµÄ¹¤³ÌÀï²åÈëÀàÄ£¿é²¢ÇÒÔÚÄ£¿éÀïÌí¼Ó´úÂ롣Ȼ¶ø£¬¡¡
ÔÚ×ö´Ë֮ǰ£¬ÄãÐèÒª¶ÔÀàÊÇʲôҪÓÐÒ»¸ö»ù±¾µÄÁ˽⡣¡¡¡¡
Èç¹ûÄã»ØÍ·¿´Ò»Ï±¾ÕµĿªÍ·£¬ÄÇôÄã¾Í»áÖªµÀÀà´ÓijÖÖÒâÒåÉÏ˵ÊǶÔÏóÄ£°å¡£Ò»¸ö¾­³£Ê¹ÓõÄÀà¡¡
±È¾ÍÊǽ«Àà±È×÷Ò»¸öÇúÆæ¼ôÇлú¡£¾ÍÏñÇúÆæ¼ôÇлú¾ö¶¨Ä³¸öÇúÆæ×ö³ÉʲôÑùÒ»Ñù£¬ÀàµÄ¶¨Òå¾ö¶¨Ä³¡¡
¸ö¶ÔÏóÓ¦¸ÃÊÇʲôÑùÒÔ¼°ÈçºÎ×ö¡£ÔÚʵ¼ÊʹÓÃÒ»¸ö¶ÔÏóÀà֮ǰ£¬Äã±ØÐëÏÈ´´½¨Ò»¸öÀàµÄÐÂʾÀý¡£¶Ô¡¡
ÏóʾÀý¾ÍÊÇÕâЩÇúÆ档ÿ¸öʾÀý¶¼ÓÐÆäÀඨÒåµÄÌص㣨ÊôÐԺͷ½·¨£©£¬ÕýÈçÄã¿ÉÒÔʹÓÃÏàͬµÄÇøÆì¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡217¡¡

¡­¡¡Ò³Ãæ¡¡234¡­

¼ôÇлúÖÆ×÷Ðí¶àÇúÆæÒ»Ñù£¬Äã¿ÉÒÔ´´½¨¶à¸öÀàµÄʾÀý¡£Äã¿ÉÒÔ¶ÀÁ¢¸Ä±äÏàͬÀàÖеÄÈÎÒâʾÀýÖеÄÀà¡¡
µÄÿ¸öʾÀýµÄÊôÐÔ¡£¡¡¡¡
ÀàÄ£¿éÔÊÐíÄ㶨ÒåÄã×Ô¼ºµÄ×Ô¶¨ÒåÀ࣬Á¬Í¬×Ô¶¨ÒåÊôÐԺͷ½·¨¡£»ØÒäһϣ¬ÊôÐÔÊǶ¨Òå¶ÔÏóij¸öÌØ¡¡
µãµÄÆ·ÖÊ£¬ÀýÈçÍâÐΡ¢Î»Öá¢ÑÕÉ«¡¢±êÌâµÈµÈ¡£·½·¨ÊǶÔÏó¿ÉÒÔÖ´ÐеIJÙ×÷¡£Í¨¹ýÔÚÀàÄ£¿éÀïÃæ±à¡¡
дÊôÐÔ¹ý³Ì£¬Äã¿ÉÒÔ¸øÄãµÄ×Ô¶¨Òå¶ÔÏó´´½¨ÊôÐÔ¡£¶ÔÏóµÄ·½·¨Ò²¿ÉÒÔÔÚÀàÄ£¿éÀïÃæͨ¹ý±àд×Ó¹ý³Ì¡¡
»òÕߺ¯Êý¹ý³ÌÀ´´´½¨¡£ÔÚÀàÄ£¿éÀï´´½¨ÍêÄãµÄ¶ÔÏóºó£¬Äã¿ÉÒÔÏóʹÓÃÆäËüµÄÄÚÖöÔÏóÒ»ÑùʹÓÃËü¡£¡¡
ÄãÒ²¿ÉÒÔ½«¶ÔÏóÀർ³öVBA¹¤³Ì¸øÆäËüÄÜʹÓÃVBAµÄÓ¦ÓóÌÐòʹÓᣡ¡¡¡

6¡£´´½¨Àà¡¡¡¡

±¾ÕµÄÊ£Óಿ·Ö½«Ê¾·¶´´½¨ºÍʹÓÃÒ»¸ö½Ð×öCEmployeeµÄ×Ô¶¨Òå¶ÔÏóµÄ¹ý³Ì¡£¸Ã¶ÔÏ󽫴ú±íÒ»¸öÔ±¡¡
¹¤£¬¸ÃCEmployee¶ÔÏ󽫾ßÓÐÊôÐÔÀýÈ磺Id£¬FirstName£¬LastNameºÍSalary¡£ËüÒ²ÓÐÒ»¸ö·½·¨£¬¿É¡¡
ÒÔÐ޸ĵ±Ç°Ð½Ë®¡£¡¡¡¡
1¡£¡¡ÔÚ¹¤³Ìä¯ÀÀÆ÷´°¿ÚÑ¡ÔñObjColClass¡¡£¨Chap11¡£xls£©£¬²¢Ñ¡Ôñ¡°²åÈ롱£ü¡°ÀàÄ£¿é¡±¡¡¡¡
2¡£¡¡Ñ¡Ôñ¹¤³Ìä¯ÀÀÆ÷ÀïµÄÀàÄ£¿é£¬²¢Ê¹ÓÃÊôÐÔ´°¿Ú½«ÆäÖØÃüÃûΪCEmployee¡£¡¡¡¡
¼¼ÇÉ11¡­2¡¡¸øÀàÄ£¿éÃüÃû¡¡¡¡
ÿ´Î´´½¨ÐÂÀàÄ£¿éµÄʱºò£¬Çë¸ø¸öËüÒ»¸öÓÐÒ
СÌáʾ£º°´ »Ø³µ [Enter] ¼ü ·µ»ØÊéÄ¿£¬°´ ¡û ¼ü ·µ»ØÉÏÒ»Ò³£¬ °´ ¡ú ¼ü ½øÈëÏÂÒ»Ò³¡£ ÔÞһϠÌí¼ÓÊéÇ©¼ÓÈëÊé¼Ü