¿¿Æ×µç×ÓÊé > ¾­¹ÜÆäËûµç×ÓÊé > excel_vba_±à³Ì½Ì³Ì(ÍêÕû°æ) >

µÚ20²¿·Ö

excel_vba_±à³Ì½Ì³Ì(ÍêÕû°æ)-µÚ20²¿·Ö

С˵£º excel_vba_±à³Ì½Ì³Ì(ÍêÕû°æ) ×ÖÊý£º ÿҳ4000×Ö

°´¼üÅÌÉÏ·½Ïò¼ü ¡û »ò ¡ú ¿É¿ìËÙÉÏÏ·­Ò³£¬°´¼üÅÌÉ쵀 Enter ¼ü¿É»Øµ½±¾ÊéĿ¼ҳ£¬°´¼üÅÌÉÏ·½Ïò¼ü ¡ü ¿É»Øµ½±¾Ò³¶¥²¿£¡
¡ª¡ª¡ª¡ªÎ´ÔĶÁÍꣿ¼ÓÈëÊéÇ©ÒѱãÏ´μÌÐøÔĶÁ£¡



¡¡¡¡¡¡¡¡ÉÏÃæµÄÖ¸Áµ±Ç°µ¥Ôª¸ñ×ÖÌå¸ÄΪTimes¡¡New¡¡Roman¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ActiveCell¡£Font¡£Bold¡¡=¡¡True¡¡¡¡
¡¡¡¡¡¡¡¡ÉÏÃæµÄÖ¸ÁîÉèÖõ±Ç°µ¥Ôª¸ñµÄ×ÖÌåΪ´ÖÌå¡£¡¡¡¡
Variable¡¡=¡¡Object¡£Property¡¡¡¡
Variable£¨±äÁ¿£©ÊÇVB½«Òª´¢´æÊôÐÔÉèÖõĵط½µÄÃû³Æ£¬Ä㽫ÔÚµÚÈýÕÂÀïѧϰ¹ØÓÚ±äÁ¿µÄ֪ʶ¡£¡¡¡¡
¡¡¡¡¡¡±äÁ¿¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¶ÔÏó¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ÊôÐÔ¡¡¡¡
CellValue¡¡=¡¡Range£¨¡°A4¡±£©¡£Value¡¡¡¡
ÉÏÃæµÄÖ¸Áµ±Ç°A4µ¥Ôª¸ñÀïµÄÖµ±£´æµ½±äÁ¿CellValue¡£¡¡¡¡
Èç¹û¸Ã·½·¨Ã»ÓÐ×Ô±äÁ¿£¬ÄÇô¾ä·¨Ó¦¸ÃÊÇ£º¡¡¡¡
Object¡£Method¡¡¡¡
¶ÔÏóÊÇÒ»¸öռλ·û£¬ÊÇÄã·ÅÖÃÄãÏëÒª½øÈëµÄʵ¼Ê¶ÔÏóÃû³ÆµÄµØ·½¡£·½·¨Í¬ÑùÒ²ÊÇÒ»¸öռλ·û£¬Äã¿É¡¡
ÒÔÔÚÕâÀï·ÅÖÃÒª¶Ô¸Ã¶ÔÏóµÄ½øÐеIJÙ×÷µÄÃû³Æ¡£ÀýÈ磬¿ÉÒÔʹÓÃÏÂÊöÖ¸ÁîÀ´Çå³ýµ¥Ôª¸ñA4µÄ¸ñʽ£¨Òë¡¡
ÕߣºÓ¦¸ÃÊÇÄÚÈÝ£©£º¡¡¡¡
¶ÔÏó¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡·½·¨¡¡¡¡
Range£¨¡¨A4¡¨£©¡£ClearContents¡¡¡¡
Èç¹û¸Ã·½·¨¿ÉÒÔʹÓÃ×Ô±äÁ¿À´ÏÞÖÆ£¬ÄÇô¾ä·¨Îª£º¡¡¡¡
Object¡£Method¡¡£¨argument1£»¡¡argument2£»¡¡¡­¡¡argumentN£©¡¡¡¡
ÀýÈ磬ʹÓÃGoTo·½·¨£¬Äã¿ÉÒÔ¿ìËÙµØÑ¡Ôñ¹¤×÷±íÀïµÄÈκÎÇøÓò¡£GoTo·½·¨µÄ¾ä·¨Îª£º¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡46¡¡

¡­¡¡Ò³Ãæ¡¡63¡­

Object¡£GoTo£¨Reference£»¡¡Scroll£©¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡®¶ÔÏó¡£GoTo£¨²ÎÕÕ£»¡¡´°¿Ú¹ö¶¯£©¡¡¡¡
Reference×Ô±äÁ¿ÊÇÄ¿±êµ¥Ôª¸ñ»òÕßÇøÓò£¬Scroll×Ô±äÁ¿¿ÉÒÔÉ趨ΪÕ棨True£©ÈÃExcel´°¿Ú¹ö¶¯µ½¡¡
¸ÃÄ¿±êµØÖ·³öÏÖÔÚ´°¿ÚµÄ×óÉϽǣ»»òÕßÉ趨Ϊ¼Ù£¨False£©£¬´°¿Ú²»¹ö¶¯£¨ÒëÕߣºÏµÍ³Ä¬ÈÏΪFalse£©¡£¡¡
ÀýÈ磬ÏÂÃæµÄVBAÓï¾äÑ¡Ôñ¹¤×÷±íSheet1ÀïµÄµ¥Ôª¸ñP100£¬²¢ÇÒ´°¿Ú¹ö¶¯£º¡¡¡¡
Application¡£GoTo¡¡_¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Reference£º=Worksheets£¨¡¨Sheet1¡¨£©¡£Range£¨¡¨P100¡¨£©£»¡¡_¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Scroll£º=True¡¡¡¡
ÉÏÃæµÄÖ¸ÁîûÓй̶¨ÔÚÒ»ÐУ¬Ê¹ÓÃÁËÒ»ÌõÌØÊâµÄÏߣ¨Ï»®Ïߣ©½«Ëü·ÖΪ¼¸¶Î¡£ÏÂÃæµÄ²¿·Ö½«½²ÊöÕâ¡¡
¸ö¡£¡¡¡¡

8¡¡´ò¶ÏºÜ³¤µÄ¡¡VBA¡¡Óï¾ä¡¡¡¡

¾¡¹ÜÒ»ÐÐVBA´úÂë×î¶à¿ÉÒÔ°üº¬1024¸ö×Öĸ£¬µ«ÊÇ£¬ÎªÁËʹÄã¸ö¹ý³ÌÈÝÒ×ÔĶÁ£¬×îºÃ½«³¤µÄÓï¾ä´ò¡¡
¶ÏΪÁ½ÐÐÉõÖÁ¶àÐС£VBʹÓÃÒ»¸öרÃŵÄÁ¬ÐøÏߣ¨Ï»®Ïߣ©ÖÃÓÚÒ»ÐдúÂëµÄĩ⣬±íÃ÷ÏÂÒ»ÐÐÊÇÕâÐС¡
µÄÁ¬Ðø¡£ÀýÈ磺¡¡¡¡
Selection¡£PasteSpecial¡¡_¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Paste£º=xlValues£»¡¡_¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Operation£º=xlMultiply£»¡¡_¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡SkipBlanks£º¡¡=False£»¡¡_¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Transpose£º=False¡¡¡¡
Õâ¸öÁ¬Ðø·ûÊÇÏ»®Ïߣ¬Äã±ØÐëÔÚÏ»®ÏßÖ®ºó´øÒ»¸ö¿Õ¸ñ¡£¡¡¡¡
Äã¿ÉÒÔÔÚÏÂÊö¼¸ÖÖÇé¿öÖÐʹÓÃÁ¬Ðø·û£º¡¡¡¡
Äã²»¿ÉÒÔÔÚðºÅºÍµÈÓÚºÅÖ®¼äʹÓÃÁ¬Ðø·û£¬ÀýÈ磬ÏÂÃæµÄ´úÂëVBÊDz»Èϵģº¡¡¡¡
Selection¡£PasteSpecial¡¡Paste£º¡¡_¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡=xlValues£»¡¡Operation£º¡¡_¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡=xlMultiply£»¡¡SkipBlanks£º¡¡_¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡=False£»¡¡Transpose£º¡¡_¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡=False¡¡Selection¡£PasteSpecial¡¡Paste£º¡¡_¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡=xlValues£»¡¡Operation£º¡¡_¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡=xlMultiply£»¡¡SkipBlanks£º¡¡_¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡=False£»¡¡Transpose£º¡¡_¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡=False¡¡¡¡
ͬÑù£¬ÔÚÒýºÅÖ®ÄÚµÄÎı¾Ö®¼ä¼ÓÁ¬Ðø·ûÒ²ÊDz»¶ÔµÄ£¬ÀýÈ磬ÏÂÃæµÄÏ»®ÏßµÄʹÓÃÊÇÎÞЧµÄ£º¡¡¡¡
MsgBox¡¡¡¨To¡¡continue¡¡the¡¡long¡¡instruction£»¡¡use¡¡the¡¡_¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡line¡¡continuation¡¡character¡£¡¨¡¡¡¡
ÉÏÃæµÄÖ¸ÁîÓ¦¸Ã´ò¶ÏΪÈçÏ´úÂ룺¡¡¡¡
MsgBox¡¡¡¨To¡¡continue¡¡the¡¡long¡¡instruction£»¡¡use¡¡the¡¡¡¨¡¡&¡¡_¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¨line¡¡continuation¡¡character¡£¡¨¡¡¡¡

9¡¡Á˽⡡VBA¡¡´íÎó¡¡¡¡

ÔÚ±àд»ò±à¼­VBA¹ý³ÌÖ®ÖУ¬ÎÞÂÛÄã¶àÃûСÐÄ£¬³ö´íµÄ¿ÉÄÜÐÔ»¹ÊǺܴòµÄ¡£ÀýÈ磬Äã¿ÉÒÔ´íÎóƴд¡¡
Ò»Óï¾ä£¬·Å´íÁËÒ»¸ö¶ººÅ»òÒýºÅ£¬»òÕßÍü¼ÇÁËÒ»¸ö¾äºÅ»òÓÒÀ¨ºÅ¡£ÕâЩÀàÐ͵ĴíÎó³ÆΪ¾ä·¨´íÎ󡣡¡
ÐÒÔ˵ÄÊÇ£¬VB±È½ÏÈÝÒ×°ïÖúÄã·¢ÏÖÕâÖÖÀàÐ͵ĴíÎó¡£ÎªÁËÈÃVBÔÚÄãÊäÈëÒ»ÐдúÂëºó£¬×Ô¶¯°ïÄã¼ì²â¡¡
Óï·¨µÄÕýÈ·ÐÔ£¬ÄãÐèÒªÔÚVB´°¿ÚµÄ¡°¹¤¾ß¡±£­¡°Ñ¡ÏÀȷ±£¹´Ñ¡ÁË¡°±à¼­Æ÷¡±Ò³Éϵġ°×Ô¶¯Óï¡¡
·¨¼ì²â¡±¡£¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡47¡¡

¡­¡¡Ò³Ãæ¡¡64¡­

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
ͼ2£­7¡¡Ñ¡Ïî¶Ô»°¿òµÄ±à¼­Æ÷Éϵġ°×Ô¶¯Óï·¨¼ì²â¡±°ïÄã¼ì²éVBA¹ý³ÌÀïµÄ´ò×Ö´íÎó¡¡¡¡
µ±VB·¢ÏÖÓï·¨´íÎóʱ£¬µ¯³öÒ»¸ö´íÎóÐÅÏ¢¿ò£¬²¢ÇÒ½«ÓÐÎóµÄ´úÂëÐÐÑÕÉ«±äΪºìÉ«£¨²Î¼ûͼ2£­8£©»ò¡¡
ÕßÆäËüÔÚÑ¡Ïî¶Ô»°¿ò¡°±à¼­Æ÷¸ñʽ¡±Ò³É趨µÄÑÕÉ«¡£Èç¹û´íÎóÐÅÏ¢¿òÉϵĽâÊͲ»¹»Çå³þ£¬Äã×ÜÊÇ¿É¡¡
ÒÔµã»÷¡°°ïÖú¡±°´Å¥Ñ°Çó¸ü¶àµÄ°ïÖú¡£ÔÙÈç¹ûVBÔÚÏß°ïÖúÎÞ·¨¸øÄãÌṩÕýÈ·µÄ·½Ïò£¬ÄÇô·µ»ØÄãµÄ¡¡
³ÌÐò£¬×Ðϸ¼ì²éÓÐÎóµÄÄÇÐдúÂëÊÇ·ñ©µôÁË×Öĸ£¬ÒýºÅ£¬¾äºÅ£¬Ã°ºÅ£¬µÈÓںţ¬×óÀ¨ºÅºÍÓÒÀ¨ºÅµÈ¡£¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
ͼ2£­8¡¡Õâ¸ö´íÎóÓÉÓÚ©µôÁ˳£ÊýxlCellTypeÇ°ÃæµÄÀ¨ºÅ¶ø²úÉú¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡48¡¡

¡­¡¡Ò³Ãæ¡¡65¡­

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
ͼ2£­9¡¡µ±VBÊÔͼÔÚ¹¤×÷±í»òµ¥Ôª¸ñÇøÓòÀïÑ¡ÔñÒ»¸ö²¢²»´æÔڵĵ¥Ôª¸ñʱ£¬¾Í»á²úÉúÒ»¸öÔËÐÐʱ¼ä¡¡
´íÎó¡¡¡¡
²éÕÒÓï·¨´íÎó¿ÉÄÜÊÇ·³È˵IJ¢ÇÒ·ÑʱµÄÊÂÇé¡£ÓÐЩÓï·¨´íÎóÖ»ÓÐÔÚ¹ý³ÌÔËÐеÄʱºò²ÅÄܱ»·¢ÏÖ¡£ÔÚ¡¡
ÊÔͼÔËÐÐÄãµÄ¹ý³ÌµÄʱºò£¬VB¿ÉÄÜÕÒµ½ÄÇÖÖÒòΪʹÓÃÁËÎÞЧµÄ×Ô±äÁ¿£¬»òÕßÊÇ©µôÁËÄÇЩÐèÒª³É¶Ô¡¡
ʹÓõÄÖ¸ÁîÈçIfÓï¾äºÍÑ­»·½á¹¹£¬¶øÔì³ÉµÄ´íÎ󡣡¡¡¡
¼¼ÇÉ2£­5£º³ÌÐòµ÷ÊÔ¡¡¡¡
ÄãºÜ¿ÉÄܲ»Ö»Ò»´ÎÌý¹ý¡°¼ÆËã»ú³ÌÐòÀï³äÂúÁË´íÎ󡱡£ÔÚ±à³ÌÀ´íÎó¾Í±»³ÆΪ¡°bug¡±£¨´íÎó£¬Â©¡¡
¶´£©£¬¶ø¡°µ÷ÊÔ¡±£¨debug£©ÔòÊǸøÄãµÄ³ÌÐò³ý´íµÄ¹ý³Ì¡£µ÷ÊԵĵÚÒ»²½¾ÍÊǸÄÕýËùÓеÄÓï·¨´íÎ󡣡¡
VBÌṩÁËÎÞÊýÖÖ¹¤¾ß£¬Äã¿ÉÒÔʹÓÃËüÃÇÀ´×·×ÙºÍÏû³ý´íÎó¡£ÔÚ±¾ÕÂÖУ¬Ä㽫֪µÀÈçºÎʹÓÃVBÖúÊÖ°ï¡¡
ÖúÄãÔÚ±àд³ÌÐòʱ³öÏÖ¾¡¿ÉÄÜÉٵĴíÎó£»ÔÚµÚÊ®ÈýÕÂÖУ¬Ä㽫ѧϰÈçºÎʹÓÃרÃŵĵ÷ÊÔ¹¤¾ßÀ´²¶»ñ¡¡
ÄãVBA³ÌÐòÀïµÄ´íÎ󡣡¡¡¡
³ýÁËÓï·¨´íÎóÍ⣬»¹ÓÐÆäËüÁ½ÖÖ´íÎó£ºÔËÐÐʱ¼äºÍÂß¼­¡£ÔËÐÐʱ¼ä´íÎó·¢ÉúÔÚ¹ý³ÌÔËÐеÄʱºò¡£Í¼¡¡
2£­9ÏÔʾÁËÒ»ÖÖµäÐ͵ÄÔËÐÐʱ¼ä´íÎó¡£ÔËÐÐʱ¼ä´íÎó¾­³£·¢ÉúÔÚÄÇЩ³ÌÐòÔ±ÔÚ±àд´úÂëµÄʱºòûÓС¡
Ïëµ½µÄÇé¿ö¡£ÀýÈ磬µ±³ÌÐòÊÔͼ·ÃÎÊÒ»¸öÓû§µçÄÔÉϲ¢²»´æÔÚµÄÇý¶¯Æ÷»òÕßÎļþ£¬»òÕßûÓÐÊ×Ïȼ졡
²éÊÇ·ñÓû§²åÈëÈíÅ̲¢¹Ø±ÕÈíÇý¿Ú¶øÊÔͼ¸´ÖÆÒ»¸öÎļþµ½ÈíÅÌ£¬Õâʱ¾Í»á·¢ÉúÔËÐÐʱ¼ä´íÎ󡣡¡¡¡
µÚÈýÖÖ´íÎ󡪡ªÂß¼­´íÎó£¬Í¨³£²»»á·¢³öÃ÷È·µÄ´íÎóÐÅÏ¢¡£¹ý³Ì¿ÉÄÜûÓÐÓï·¨´íÎó£¬ÉõÖÁÔËÐÐÎÞÎ󣬡¡
È»¶ø£¬µÃµ½µÄÈ´ÊÇ´íÎóµÄ½á¹û¡£Âß¼­´íÎóͨ³£·Ç³£ÄÑÒÔ²éÕÒ£¬²¢ÇÒËü²ØµÃºÜÒþÃØ£¬¼äЪ·¢Éú£¬Äã²»¡¡
ÄÜÖ¸Íû»¨¼¸¸öСʱ£¬ÉõÖÁ¼¸Ì죬¾ÍÄÜÕÒµ½´íÎóÔ´¡£¡¡¡¡

10¡¡²éÕÒ°ïÖú¡¡¡¡

µ±ÄãʹÓúê¼ÖÆÆ÷ʱ£¬ÄãËùÓеIJÙ×÷¶¼±»·­Òë³ÉVBAÖ¸Á²¢ÇÒ·ÅÖÃÔÚÒ»¸öÄ£¿éÀï¡£ÄãÔÚÑо¿ÕâЩ¡¡
¼ÖƵĹý³Ìʱ£¬²»ÒªÍü¼Ç°ïÖúËæʱ¿ÉÓá£Äã»á·¢ÏÖÓÐЩ´úÂëµÄÒâ˼¿ÉÄÜ»á·Ç³£Ò׶®£¬È»¶ø£¬ÓÐЧȴ¡¡
²»ÔõôÃ÷°×¡£Õâʱºò£¬Äã¾ÍÐèҪѰÇó°ïÖúÁË¡£µ±Äã¶À×Ô¹¤×÷ʱ£¬Ö»ÒªÇáÇáÒ»µã»òÕßÇáÇáÒ»°´¾Í¿ÉÒÔ¡¡
Çë½ÌÄãµÄVBAÀÏʦÁË¡£Ê¹ÓÃVBÔÚÏß°ïÖú±ÈʹÓôʵä»ò²Î¿¼ÊÖ²áÒª¿ì½ÝºÍÈÝÒ׵öࡣÈç¹ûÄãÌÖÑáÒ»Ò³¡¡
Ò»Ò³µØÔڴʵäÀïÕÒÄãÐèÒªµÄÊõÓÄ㽫¾ªÑÈÓÚÄãÈçºÎ¿ìµØ´ÓVB´úÂë´°¿ÚÕÒµ½ÐèÒªµÄ°ïÖúÒ³Ãæ¡£¡¡¡¡
ÈÃÎÒÃÇÀ´¼ì²éÄãÈçºÎͨ¹ýÄÚÖõÄVBAÀÏʦµÄ°ïÖú£¬½«WhatsInACell¹ý³ÌÀïµÄµÚÒ»¾ä±ä³ÉÄã×Ô¼ºµÄVBA¡¡
´Ê»ã£º¡¡¡¡
Selection¡£SpecialCells£¨xlCellTypeConstants£»¡¡2£©¡£Select¡¡¡¡
ÉÏÃæµÄÖ¸Áî¿ÉÒÔ´ò¶ÏΪÈý²¿·Ö£¬ÄÄЩ²¿·Ö£¿SelectionÊǶÔÏó»¹ÊÇÊôÐÔ£¿SpecialCellsÊÇʲô£¿¡¡
SelectÊÇʲô£¿Òª»Ø´ðÕâЩÎÊÌ⣬ÇëÒÀÕÕÏÂÃæµÄ²Ù×÷£º¡¡¡¡
1¡£¡¡¡¡¼¤»îÄãÒª·ÖÎöµÄ¹ý³ÌµÄ´úÂë´°¿Ú¡¡¡¡
2¡£¡¡¡¡µã»÷Äã²»¶®µÄ´ÊÓï¡¡¡¡
3¡£¡¡¡¡°´ÏÂF1¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡49¡¡

¡­¡¡Ò³Ãæ¡¡66¡­

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
ͼ2£­10¡¡VBAµÄ¶ÔÏó£¬ÊôÐԺͷ½·¨ÔÚÔÚÏß°ïÖúÀï½âÊ͵úÜÏêϸ¡¡¡¡
°ïÖú¾Í»áÏÔʾÏàÓ¦µÄÒ³Ãæ¡£Èç¹ûÄãµÄ¹â±ê·ÅÔÚ´ÊÓï¡°Selection¡±Öм䣬Äã¾Í»áÖªµÀSelection¿ÉÒÔ¡¡
ÊÇÒ»¸öÓ¦ÓóÌÐòµÄÊôÐÔ£¬Ò²¿ÉÒÔÊÇÒ»¸ö´°¿Ú¶ÔÏó¡£Èç¹ûÄãµÄ¹â±êÔÚÏÂÒ»¸ö²»Ã÷°×µÄÊõÓï¡¡
¡¡£¨SpecialCells£©²¢ÇÒ°´ÉÏÃæµÄ²½ÖèÔÙ×öÒ»±éºó£¬Ä㽫¿´µ½SpecialCells°ïÖúÆÁÄ»¡¡£¨²Î¼ûͼ2£­10£©¡£¡¡
×¢Ò⣬ÿ¸ö°ïÖúÖ÷Ìâ°üº¬Ðí¶àÐÅÏ¢¡£±»²éÕÒµÄÖ¸ÁîÀàÐÍÏÔʾÔÚ°ïÖú´°¿ÚµÄÉÏÃ棻ָÁîµÄÀàÐÍÔÊÐí´Ê¡¡
Óï·ÖÀà¡£ÀýÈ磬SpecialCellsÊÇ·½·¨£¬¿ÉÒÔʹÓÃÕâ¸ö·½·¨µÄ¶ÔÏóÃû³ÆÁÐÔÚ¡°Ó¦ÓÃÓÚ¡±ÏÂÃ棨ÒëÕߣº¡¡
µã»÷¡°Ó¦ÓÃÓÚ¡±£¬³öÏÖ¶ÔÏóÃû³ÆÁÐ±í£©¡£Ö¸ÁîÃû³ÆÏÂÃæµÄ¡°²ÎÔÄ¡±ºÍ¡°Ê¾Àý¡±ÈÃÄã¿ìËÙµØÌøµ½ÆäËüÓ¦¡¡
ÓûòÒâÒåÏàËƵÄÖ¸ÁÒÔ¼°²é¿´Ê¹ÓÃÕâ¸öÖ¸ÁîµÄÀý×Ó¡£Ö¸ÁîµÄÒâÒåÏÔʾÔÚ¡°²ÎÔÄ¡±ºÍ¡°Ê¾Àý¡±±êÌâ¡¡
µÄÏÂÃæ¡£½ÓÏÂÀ´ÔòÊÇÓï·¨ºÍÐèÒªµÄ×Ô±äÁ¿ºÍÆäËü²ÎÊý¡£¡°ËµÃ÷¡±²¿·Ö¸ø³öһЩÍƼöʹÓøÃÖ¸ÁîµÄÇé¡¡
ÐΡ£¡¡¡¡
Äã¿ÉÒÔºÜÈÝÒ׵ؽ«Ê¾ÀýÖеĴúÂ븴ÖƵ½ÄãµÄ¹ý³ÌÖÐÈ¥£ºÑ¡ÖÐÄãÒª¸´ÖƵĴúÂëÐУ¬°´ÏÂCtrl£«C£¬»òÕß¡¡
µ¥»÷ÓÒ¼ü£¬Ñ¡Ôñ¿ì½Ý²Ëµ¥Éϵġ°¸´ÖÆ¡±£¬È»ºóÇл»µ½VB´úÂë´°¿Ú£¬µã»÷ÄãÐèÒªÕ³Ìù´úÂëµÄµØ·½£¬ÔÙ¡¡
°´ÏÂCtrl£«V»òÕßÑ¡Ôñ¡°±à¼­¡±£­¡°Õ³Ìù¡±¡£¡¡¡¡

11¡¡Óï·¨ºÍ±à³Ì¿ì½ÝÖúÊÖ¡¡¡¡

VB±à¼­Æ÷´°¿ÚÉϵġ°±à¼­¡±¹¤¾ßÌõÉÏÓкܶఴť£¬°ïÖúÄã¿ìËÙÈÝÒ×µØÊäÈëÕýÈ·¸ñʽµÄVBAÖ¸Áî¡£Èç¡¡
¹û¡°±à¼­¡±¹¤¾ßÌõÄ¿Ç°ÔÚVB±à¼­Æ÷´°¿ÚÉϲ»¿ÉÁ¬½Ó£¬ÄÇôÄã¿ÉÒÔÑ¡Ôñ¡°ÊÓͼ¡±£­¡°¹¤¾ßÌõ¡±¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
ͼ2£­11¡¡±à¼­¹¤¾ßÌõÉϵݴťʹµÃ±àд³ÌÐòºÍÉèÖÃÖ¸Áî¸ñʽ±äµÃºÜÈÝÒס¡¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡50¡¡

¡­¡¡Ò³Ãæ¡¡67¡­

ÔÚVBÖбàд¹ý³ÌÐèÒªÄãʹÓóɰÙÉÏǧµÄÄÚÖÃÖ¸ÁîºÍº¯Êý¡£ÒòΪ´ó¶àÊýÈËÃÇÎÞ·¨Ñ§Ï°ËùÓÐVBAÀï¿ÉÓá¡
Ö¸ÁîµÄÓï·¨£¬IntelliSenseÌṩÁËÄãËùÐèÇóµÄÓï·¨ºÍ±à³Ì°ïÖú¡£µ±ÄãÔÚ´úÂë´°¿Ú±à³Ìʱ£¬¾­³£»áÓС¡
רÃŵĴ°¿Úµ¯³öÀ´£¬Òýµ¼ÄãÍê³ÉÕýÈ·µÄVBA´úÂë¡£¡¡¡¡

12¡¡ÊôÐÔ/·½·¨ÁÐ±í¡¡¡¡

ÿ¸ö¶ÔÏ󶼻áÓÐÐí¶àÊôÐԺͷ½·¨¡£µ±ÄãÊäÈëÒ»¸ö¶ÔÏóÃû³ÆºÍÒ»¸ö¾äºÅÒÔ·Ö¿ªÕâ¸ö¶ÔÏóÃû³ÆºÍËüµÄÊô¡¡
ÐÔ»ò·½·¨Ê±£¬µ¯³öÒ»¸öÁбí²Ëµ¥¡£Õâ¸ö²Ëµ¥ÁгöÁËÔÚÕâ¸ö¾äºÅ֮ǰµÄ¶ÔÏóµÄËùÓпÉÓõÄÊôÐԺͷ½·¨¡¡
¡¡£¨²Î¼ûͼ2£­12£©¡£ÈçºÎ´ò¿ªÕâ¸ö×Ô¶¯¹¤¾ß£¿Ñ¡Ôñ¡°¹¤¾ß¡±£­¡°Ñ¡Ï£¬µ¥»÷Ñ¡Ïî¶Ô»°¿òÉϵġ°±à¼­¡¡
Æ÷¡±Ò³£¬È·±£¹´Ñ¡ÉÏ¡°×Ô¶¯Áгö³ÉÔ±¡±¡£¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
ͼ2£­12¡¡ÔÚÊäÈëVBAÖ¸Áîʱ£¬VB»á½¨Òé¿ÉÒÔÓÃÓڸöÔÏóµÄÊôÐԺͷ½·¨¡¡¡¡
ÈçºÎ´Óµ¯³ö²Ëµ¥£¨Í¼2£­12£©ÉÏÑ¡ÔñÏîÄ¿£¿ÊÔͼÊäÈëÄãÐèÒªµÄÊôÐÔ»ò·½·¨Ãû³ÆµÄÇ°¼¸¸ö×Öĸ£¬µ±Excel¡¡
Í»³öÏÔʾÁËÕýÈ·µÄÏîÄ¿Ãû³Æ£¬Ôò»Ø³µ£¬²åÈë¸ÃÏîÄ¿µ½ÄãµÄ´úÂëÖÐÈ¥£¬²¢ÇÒ¿ªÊ¼ÐµÄÒ»ÐУ»»òÕߣ¬Äã¡¡
ÐèÒªÔÚͬһÐмÌÐøд´úÂ룬ÄÇô¾Í°´Tab¼ü´úÌæ»Ø³µ¡£ÄãÒ²¿ÉÒÔË«»÷¸ÃÏîÄ¿À´²åÈëµ½´úÂëÖÐÈ¥¡£Ö»¡¡
Òª°´Esc¼ü¾Í¿ÉÒԹرÕÕâ¸öµ¯³ö²Ëµ¥£¬¶ø²»²åÈëÈκÎÏîÄ¿¡£µ±Äã°´Esc¼üÈ¡ÏûÁ˵¯³ö²Ëµ¥ºó£¬VB½«²»¡¡
»á¶ÔͬÑùµÄ¶ÔÏóÏÔʾ¸Ã²Ëµ¥¡£Äã¿ÉÒÔͨ¹ýÒÔÏ·½·¨À´ÔÙ´ÎÏÔʾÊôÐÔ/·½·¨µ¯³ö²Ëµ¥£º¡¡¡¡

13¡¡³£ÊýÁÐ±í¡¡¡¡

±¾ÕµÄÇ°Ã棬ÄãѧϰÁ˸øÊôÐÔ¸³Öµ£¬ÐèҪʹÓÃÏÂÃæ¹æÔò£º¡¡¡¡
Object¡£Property¡¡=¡¡Value¡¡¡¡
Èç¹ûÑ¡Ïî¶Ô»°¿ò£¨±à¼­Æ÷Ò³£©ÒѾ­¹´Ñ¡ÁË¡°×Ô¶¯Áгö³ÉÔ±¡±£¬Excel¾Í»áÔڵȺÅÇ°µÄÊôÐÔµ¯³öÒ»¸ö²Ë¡¡
µ¥£¬Áгö¸Ã¶ÔÊôÐÔÓÐЧµÄ³£Êý¡£³£ÊýÊDZíÃ÷È·ÇеÄÃèÊö»òÕß½á¹ûµÄÖµ¡£ExcelºÍOfficeÀïÃæµÄÆäËü¡¡
Ó¦ÓÃÈí¼þ¶¼ÓкܶàÔ¤Ïȶ¨ÒåµÄÄÚÖó£Êý¡£Ä㽫ÔÚµÚÈýÕÂÖÐѧϰ³£Êý£¬³£ÊýÀàÐͺÍʹÓᣡ¡¡¡
¼ÙÉèÄãÐèÒªÄãµÄ³ÌÐò´ò¿ªExcel¹¤×÷±íÉϵķÖÒ³Ô¤ÀÀ¡£¡°±à¼­¡±£¨ÒëÕߣºÊÓͼ£©²Ëµ¥ÉÏÓÐÁ½¸öÑ¡Ôñ£º¡¡
ÆÕͨÊÓͼºÍ·ÖÒ³Ô¤ÀÀ¡£ÆÕͨÊÓͼÊǾø´ó¶àÊýExcelÈÎÎñµÄĬÈÏÊÓͼģʽ£»·ÖÒ³Ô¤ÀÀÔòÊDZ༭ÊÓͼ£¬¡¡
ÏÔʾ¹¤×÷±íÖÐÓÐÄÚÈݵÄÇøÓò¡£ÕâÁ½ÖÖÑ¡ÏÓÐÏàÓ¦µÄÄÚÖó£ÊýÀ´±íʾ¡£Excel³

·µ»ØĿ¼ ÉÏÒ»Ò³ ÏÂÒ»Ò³ »Øµ½¶¥²¿ ÔÞ£¨0£© ²È£¨0£©

Äã¿ÉÄÜϲ»¶µÄ