±´¿Çµç×ÓÊé > »ù´¡¿Æѧµç×ÓÊé > excel_vba_±à³Ì½Ì³Ì(ÍêÕû°æ) >

µÚ25ÕÂ

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

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

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



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Sub¡¡¡¡
RmDir·½·¨ÔÊÐíÄã´ÓÓ²ÅÌÉÏɾ³ý²»ÐèÒªµÄÎļþ¼Ð¡£¡¡¡¡

21¡¡ÓöÔÏóä¯ÀÀÆ÷À´¶¨Î»¹ý³Ì¡¡¡¡

³ýÁ˶¨Î»¶ÔÏó£¬ÊôÐԺͷ½·¨Í⣬¶ÔÏóä¯ÀÀÆ÷»¹ÊǸö¶¨Î»ÔÚ²»Í¬¹¤³ÌÀïÃæµÄ¹ý³Ì·Ç³£·½±ãµÄ¹¤¾ß¡£Ï¡¡
ÃæµÄÀý×Ó¸øÄãÑÝʾÈçºÎ²é¿´´æÔÚ¡°Personal¡±¹¤×÷²¾ÀïÃæµÄ¹ý³Ì£º¡¡¡¡
1¡£¡¡¡¡¼¤»î¶ÔÏóä¯ÀÀÆ÷²¢ÇÒÑ¡Ôñ¹¤³Ì/¿âÏÂÀ­ÁбíÀïµÄPersonal¡££¨ÒëÕߣºÒòΪÎÒûÓÐPersonalÕâ¸öÎÄ¡¡
¡¡¡¡¡¡¡¡¡¡¼þ¡£¡£¡££©¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
ͼ2£­22¡¡¶ÔÏóä¯ÀÀÆ÷ÁгöËùÓÐÔÚij¸öÌض¨VBA¹¤³ÌÀï¿ÉÓõĹý³Ì¡¡¡¡
¶ÔÏóä¯ÀÀÆ÷µÄ×ó±ßÏÔʾËùÑ¡¹¤³ÌÀïÃæ¶ÔÏóÃû³Æ£¬¶øÓÒ±ßÔòÁгöÁËËùÓпÉÓõĹý³Ì¡£¡¡¡¡
2¡£¡¡¡¡Ë«»÷NewFolder¹ý³ÌÃû³Æ£¬VB½«¹â±ê¶¨Î»µ½¸Ã¹ý³ÌµÄµÚÒ»ÐС¡¡¡
3¡£¡¡¡¡¹Ø±Õ¶ÔÏóä¯ÀÀÆ÷¡¡¡¡

22¡¡Ê¹ÓÃÁ¢¼´´°¿Ú¡¡¡¡

ÔÚÄ㿪ʼ´´½¨Ò»¸öÍêÉƵÄVBA¹ý³ÌÇ°£¨ÔÚÏÂÒ»Õ£©£¬ÏÈÀ´×öһЩÈÈÉíÁ·Ï°£¬Ôö¼ÓÄãµÄVBA´Ê»ã¡£ÄãÔõ¡¡
Ñù²ÅÄÜѧµÃ¿ì¶øÇÒûÓÐÍ´¿à£¿ÄãÈçºÎÊÔÑéÒ»ÏÂһЩÐÂѧµÄVBAÖ¸ÁÕâÀïÓÐһЩ¼ò¶ÌµÄ£¬»¥¶¯µÄÓï¡¡
ÑÔÁ·Ï°£ºÊäÈëÒ»¸ö¼òµ¥µÄVBAÖ¸ÁExcel»á¼ì²é²¢ÇÒ½«½á¹ûÏÔʾÔÚÏÂÒ»ÐС£ÎÒÃÇ¿ªÊ¼À´É趨ÄãµÄÁ·¡¡
Ï°ÆÁÄ»£º¡¡¡¡
1¡£¡¡¡¡ÔÚVB±à¼­Æ÷´°¿Ú£¬Ñ¡Ôñ¡°ÊÓͼ¡±£­¡°Á¢¼´´°¿Ú¡±¡¡¡¡
ÔÚ¾ö¶¨Ê¹ÓÃÔÚÄã×Ô¼ºµÄVBA¹ý³Ì֮ǰ£¬Á¢¼´´°¿Ú¿ÉÒÔÓÃÀ´ÊÔÑéVBÓïÑÔÖв»Í¬µÄÖ¸Áº¯ÊýºÍÔËËã·û¡£¡¡
ÕâÊÇÒ»¸ö·Ç³£ºÃµÄµ÷ÊÔÐÂÓïÑԵŤ¾ß£¬ÄãÊäÈëÔÚÕâ¸ö´°¿ÚÀïÃæµÄÖ¸Á½«»áÁ¢¼´ÏÔʾ½á¹û¡£¡¡¡¡
Á¢¼´´°¿Ú¿ÉÒÔÔÚVB±à¼­Æ÷´°¿ÚÉÏÈÎÒâÒƶ¯£¬Ò²¿ÉÒÔÉèÖÃΪ¿ÉÁ¬½ÓµÄ£¬ÕâÑùËü¾Í»á³öÏÖÔÚÏàͬµÄµØ·½¡£¡¡
¿ÉÒÔͨ¹ýÑ¡Ïî¶Ô»°¿òÉϵġ°¿ÉÁ¬½ÓµÄ¡±Ò³À´´ò¿ª»ò¹Ø±Õ¿ÉÁ¬½ÓÉèÖá£ÔÚVB±à¼­Æ÷´°¿ÚÉÏ°´ÏÂCtrl£«G¡¡
¾Í¿ÉÒÔ¿ìËÙ·ÃÎÊÁ¢¼´´°¿Ú¡£Á¢¼´´°¿ÚÔÊÐíÄãÊäÈëVBAÓï¾ä£¬²¢ÇÒ²âÊÔËüÃǵĽá¹û£¬¶ø²»ÐèҪд³ÉÒ»¡¡
¸ö¹ý³Ì¡£Á¢¼´´°¿Ú¾ÍÏñÒ»¸ö²Ý¸å°å£¬Äã¿ÉÒÔÓÃËü²âÊÔÄãµÄÓï¾ä¡£Èç¹û¸ÃÓï¾äÊä³öÁËÄãÏ£ÍûµÄ½á¹û£¬¡¡
Äã¾Í¿ÉÒÔ½«Á¢¼´´°¿ÚÉϵÄÓï¾ä¸´ÖƵ½ÄãµÄ¹ý³ÌÖÐÈ¥£¨»òÕߣ¬ÄãÒ²¿ÉÒÔ½«Óï¾äÍÏÒ·µ½´úÂë´°¿Ú£¬Èç¹û¡¡
´úÂë´°¿ÚÊǿɼûµÄ£©¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡59¡¡

¡­¡¡Ò³Ãæ¡¡76¡­

2¡£¡¡¡¡½«ExcelºÍVB±à¼­Æ÷´°¿Ú²¢ÅÅÅÅÁС¡¡¡
3¡£¡¡¡¡ÔÚÁ¢¼´´°¿ÚÀïÊäÈëÏÂÊöÖ¸Á²¢Çһسµ¡¡¡¡
¡¡¡¡¡¡¡¡Worksheets£¨¡¨Sheet2¡¨£©¡£Activate¡¡¡¡
µ±Äã°´Ï»سµ¼ü£¬VB¿ªÊ¼¹¤×÷£¬Èç¹ûÄãÉÏÃæÊäÈëµÄÓï¾äÊÇÕýÈ·µÄ»°£¬VBA¼¤»îµ±Ç°¹¤×÷²¾ÀïµÄµÚ¶þ¡¡
¸ö¹¤×÷±í¡£¹¤×÷²¾µ×²¿µÄSheet2ÕâʱӦ¸ÃÊÇÍ»³öÏÔʾµÄ¡£¡¡¡¡
4¡£¡¡¡¡ÔÚÁ¢¼´´°¿Ú£¬ÊäÈëÆäËüVBAÓï¾ä²¢»Ø³µ¡¡¡¡
¡¡¡¡¡¡¡¡Range£¨¡¨A1£ºA4¡¨£©¡£Select¡¡¡¡
ÄãÒ»µ©°´Ï»سµ£¬VB½«Ñ¡Öе±Ç°¹¤×÷±íµÄA1£¬A2£¬A3ºÍA4¡¡¡¡
5¡£¡¡¡¡ÔÚÁ¢¼´´°¿ÚÀïÊäÈëÏÂÊöÖ¸Á¡¡¡¡
¡¡¡¡¡¡¡¡£§A1£ºA4£§¡£Value¡¡=¡¡55¡¡¡¡
µ±Äã°´Ï»سµ£¬VBÔÚA1£ºA4ÖеÄÿ¸öµ¥Ôª¸ñÀï·ÅÖÃÊý×Ö55¡£ÉÏÃæµÄÓï¾äÊÇÒýÓÃRange¶ÔÏóµÄÒ»ÖÖËùд¡¡
·½Ê½£¬ÍêÕûµÄÓï·¨¿É¶ÁÐÔ¸üÇ¿£º¡¡¡¡
¡¡¡¡¡¡¡¡Range£¨¡¨A1£ºA4¡¨£©¡£Value¡¡=¡¡55¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
ͼ2£­23¡¡½«ExcelºÍVB´°¿Ú²¢ÅÅÅÅÁÐÈÃÄã¿ÉÒÔ¹Û²ìÖ¸ÁîµÄÔËÐС¡¡¡
6¡£¡¡¡¡ÔÚÁ¢¼´´°¿ÚÊäÈëÏÂÊöÖ¸Á¡¡¡¡
¡¡¡¡¡¡¡¡Selection¡£ClearContents¡¡¡¡
»Ø³µºó£¬VBAÇå³ýËùÑ¡µ¥Ôª¸ñÇøÓòµÄÄÚÈÝ£¬ÇøÓòA1£ºA4ÏÖÔÚÊǿյġ¡¡¡
7¡£¡¡¡¡ÔÚÁ¢¼´´°¿ÚÊäÈëÏÂÊöÖ¸Á¡¡¡¡
¡¡¡¡¡¡¡¡ActiveCell¡£Select¡¡¡¡
»Ø³µºó£¬VB¼¤»îA1µ¥Ôª¸ñ¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
ͼ2£­24¡¡ÔÚÁ¢¼´´°¿ÚÀïÊäÈëÖ¸Áһµ©Äã°´Ï»سµ¼ü£¬Ö¸Áî¾Í»á±»Ö´ÐС¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡60¡¡

¡­¡¡Ò³Ãæ¡¡77¡­

ͼ2£­24ÏÔʾÁËÉÏÃæÁ·Ï°ÖÐÔÚÁ¢¼´´°¿ÚÀïÊäÈëµÄËùÓÐÖ¸Áî¡£Äãÿ´Î°´Ï»سµ¼üºó£¬Excel×ÜÊÇÖ´Ðй⡡
±êËùÔÚÐеÄÓï¾ä¡£Èç¹ûÄãÏëÒªÔÙ´ÎÖ´ÐÐͬһָÁÄÇôµã»÷¸ÃÖ¸ÁîÐеÄÈÎÒâλÖ㬻سµ¡£ÎªÁ˸ü¶à¡¡
µÄÁ·Ï°£¬ÖØÐÂÔËÐÐͼ2£­24ÀïÓï¾ä£¬´ÓÁ¢¼´´°¿ÚµÄµÚ¶þÐÐÖ¸Áʼ£¬µã»÷ºÏÊʵĵط½²¢»Ø³µ£¬Ò»¸ö¡¡
Ò»¸öµØÖ´ÐÐÕâЩָÁî¡£¡¡¡¡

23¡¡»ñÈ¡Á¢¼´´°¿ÚÀïµÄÐÅÏ¢¡¡¡¡

µ½Ä¿Ç°ÎªÖ¹£¬ÄãÒѾ­Ê¹ÓÃÁ¢¼´´°¿ÚÖ´ÐвÙ×÷ÁË£¬ÕâЩ²Ù×÷Ò²¿ÉÒÔÊÇÊÖ¶¯µØÔÚ¹¤×÷±íµÄÈÎÒâÇøÓòµã»÷¡¡
Êó±ê²¢ÇÒÊäÈëÊý¾Ý¡£Á¢¼´´°¿ÚÒ²ÔÊÐíÄãÎÊÎÊÌâ¡£¼ÙÉèÄãÏëÒªÕÒµ½ÏÂÃæÎÊÌâµÄ´ð°¸£º¡°ÏÖÔÚÑ¡ÖеÄÊÇ¡¡
ÄÄЩµ¥Ôª¸ñ£¿¡±£¬¡°µ±Ç°µ¥Ôª¸ñÀïµÄÖµÊǶàÉÙ£¿¡±£¬¡°µ±Ç°¹¤×÷±íµÄÃû³ÆÊÇʲô£¿¡±£¬¡°µ±Ç°´°¿ÚµÄ±àºÅ¡¡
ÊǶàÉÙ£¿¡±Ê¹ÓÃÁ¢¼´´°¿Ú£¬Äã¿ÉÒÔÇáÒ×µØÕÒµ½ÕâЩÎÊÌ⣬ÒÔ¼°ÆäËüÎÊÌâµÄ´ð°¸¡£ÔÚÇ°ÃæµÄÀý×ÓÀ¡¡
ÄãÊäÈëÁ˺ü¸¸öÖ¸ÁÈÃÎÒÃÇ·µ»ØÁ¢¼´´°¿ÚÈ¥Îʼ¸¸öÎÊÌâ¡£ExcelÉõÖÁÔÚÄã¹Ø±ÕÁËÁ¢¼´´°¿Úºó»¹ÄÜ¡¡
¼ÇסÄãÔÚÁ¢¼´´°¿ÚÀïÊäÈëµÄÖ¸Áî¡£µ±ÄãÍ˳öExcelʱ£¬Á¢¼´´°¿ÚµÄÄÚÈÝ×Ô¶¯»á±»É¾³ý¡£¡¡¡¡
1¡£¡¡¡¡¡¡Êó±êµã»÷Á¢¼´´°¿ÚµÚ¶þÐÐÄãÊäÈëRange£¨¡¨A1£ºA4¡¨£©¡£SelectµÄÈÎÒâµØ·½¡¡¡¡
2¡£¡¡¡¡»Ø³µ£¬ÈÃExcelÔÙ´ÎÑ¡Ôñµ¥Ôª¸ñA1£ºA4¡¡¡¡
3¡£¡¡¡¡ÔÚÁ¢¼´´°¿ÚеÄÒ»ÐÐÊäÈëÏÂÃæµÄÎÊÌ⣺¡¡¡¡
¡¡¡¡¡¡¡¡£¿Selection¡£Address¡¡¡¡
µ±Äã°´»Ø³µ£¬Excel²»»áÑ¡Ôñ¹¤×÷±íµÄÈκζ«Î÷£¬È¡¶ø´úÖ®£¬Á¢¼´´°¿ÚÉÏ»áÔÚÁíÍâÒ»ÐÐÏÔʾ¸ÃÖ¸Áî¡¡
µÄ½á¹û¡£ÔÚ¸ÃÀýÖУ¬Excel·µ»ØµÄÊǵ±Ç°±»Ñ¡ÔñµÄµ¥Ôª¸ñµÄ¾ø¶ÔµØÖ·£¨A1£ºA4£©¡£Îʺţ¨£¿£©¸æËß¡¡
ExcelÔÚÁ¢¼´´°¿ÚÏÔʾָÁîµÄ½á¹û¡£³ýÁËÎʺţ¬Ä㻹¿ÉÒÔʹÓÃPrint¹Ø¼ü×Ö¡£ÈÃÎÒÃÇʹÓùؼü×ÖPrint¡¡
Îʹ¤×÷±íÃû³Æ¡¡¡¡
4¡£¡¡¡¡ÔÚÁ¢¼´´°¿ÚеÄÒ»ÐУ¬ÊäÈëÏÂÊöÎÊÌ⣺¡¡¡¡
¡¡¡¡¡¡¡¡Print¡¡ActiveWorkbook¡£Name¡¡¡¡
»Ø³µºó£¬ExcelÔÚÁ¢¼´´°¿ÚеÄÒ»ÐÐÊäÈëÁ˵±Ç°¹¤×÷²¾µÄÃû³Æ¡£¡¡¡¡
ÕÒÕÒÓ¦ÓóÌÐòµÄÃû³ÆÈçºÎ£¿Chap02¡£xlsµÄ¸¸¶ÔÏóÊÇË­£¿¡¡¡¡
5¡£¡¡¡¡ÔÚÁ¢¼´´°¿ÚеÄÒ»ÐУ¬ÊäÈëÏÂÊöÎÊÌ⣺¡¡¡¡
¡¡¡¡¡¡¡¡£¿Application¡£Name¡¡¡¡
Excel»áÏÔʾËü×Ô¼ºµÄÈ«Ãû£ºMicrosoft¡¡Excel¡¡¡¡
Á¢¼´´°¿ÚÒ²¿ÉÒÔÓÃÀ´×öÒ»¸ö¿ìËÙ¼ÆËã¡¡¡¡
6¡£¡¡¡¡ÔÚÁ¢¼´´°¿ÚеÄÒ»ÐУ¬ÊäÈëÏÂÊöÎÊÌ⣺¡¡¡¡
¡¡¡¡¡¡¡¡£¿12/3¡¡¡¡
»Ø³µºó£¬Excel»áÔÚÏÂÒ»ÐÐÏÔʾ¸Ã³ý·¨ÔËËãµÄ½á¹û¡£µ«ÊÇ£¬ÍòÒ»ÄãÏëÁ¢¼´ÖªµÀ3£«2ºÍ12*8µÄ½á¹ûÄØ£¿¡¡
Äã¿ÉÒÔ½«ËüÃÇÊäÈëÔÚÒ»ÐУ¬¶ø²»±Ø·Ö³ÉÁ½ÐУ¬ÀýÈ磺¡¡¡¡
¡¡¡¡¡¡¡¡£¿3£«2£º£¿12*8¡¡¡¡
×¢Ò⣬ðºÅ½«Á½¸ö´úÂë¿é·Ö¸î¿ªÀ´¡£¡¡¡¡
µ±Äã°´Ï»سµ¼ü£¬Excel·Ö±ðÔÚÁ¢¼´´°¿ÚµÄÁ½ÐÐÏÔʾ½á¹û5£¬96¡£¡¡¡¡
ÏÂÃæÊÇÄãÔÚÁ¢¼´´°¿ÚÀïÊäÈëµÄËùÓÐÖ¸ÁÒÔ¼°Excel¶ÔÄãÎÊÌâµÄ»Ø´ð£º¡¡¡¡
¡¡¡¡¡¡¡¡Worksheets£¨¡¨Sheet2¡¨£©¡£Activate¡¡¡¡¡¡
¡¡¡¡¡¡¡¡Range£¨¡¨A1£ºA4¡¨£©¡£Select¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡£§A1£ºA4£§¡£Value¡¡=¡¡55¡¡¡¡¡¡
¡¡¡¡¡¡¡¡Selection¡£ClearContents¡¡¡¡¡¡
¡¡¡¡¡¡¡¡ActiveCell¡£Select¡¡¡¡¡¡
¡¡¡¡¡¡¡¡£¿Selection¡£Address¡¡¡¡¡¡
¡¡¡¡¡¡¡¡A1£ºA4¡¡¡¡¡¡
¡¡¡¡¡¡¡¡Print¡¡ActiveWorkbook¡£Name¡¡¡¡¡¡
¡¡¡¡¡¡¡¡Chap02¡£xls¡¡¡¡¡¡
¡¡¡¡¡¡¡¡£¿Application¡£Name¡¡¡¡¡¡
¡¡¡¡¡¡¡¡Microsoft¡¡Excel¡¡¡¡¡¡
¡¡¡¡¡¡¡¡£¿12/3¡¡¡¡¡¡
¡¡¡¡¡¡¡¡4¡¡¡¡¡¡
¡¡¡¡¡¡¡¡£¿3£«2£º£¿12*8¡¡¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡61¡¡

¡­¡¡Ò³Ãæ¡¡78¡­

¡¡¡¡¡¡¡¡5¡¡¡¡¡¡
¡¡¡¡¡¡¡¡96¡¡¡¡
ÒªÇå³ýÁ¢¼´´°¿ÚÀïµÄÖ¸ÁֻҪѡÖÐËùÓÐÖ¸Áî²¢ÇÒ°´ÏÂDelete¼ü¡¡¡¡

24¡¡Ñ§Ï°¶ÔÏó¡¡¡¡

ÒªÔÚExcelÀï´´½¨Ò»Ð©×Ô¶¨ÒåÓ¦ÓóÌÐò£¬ÐèҪһЩ³£ÓöÔÏó»òÕ߶ÔÏ󼯺ϵŤ×÷֪ʶ£¬ÀýÈçRange£¬¡¡
Workbook¡¡£¨Workbooks£©£¬Worksheet¡¡£¨Worksheets£©£¬Window¡¡£¨Windows£©ºÍ¡¡Application¡£ÔÚÇ°Ã沿¡¡
·Ö£¬Ä㿪ÍØÁËѧϰVBµÄÐí¶à·½·¨¡£ÕâÀïÓÐÒ»¸ö×ܽá¹ØÓÚʲôʱºòʹÓÃʲô¹¤¾ß£º¡¡¡¡
¡¡¡¡¡¡¡¡Ïóä¯ÀÀÆ÷¡¡¡¡
±¾ÕÂÊ£ÓàµÄ¼¸Ò³ÀïÓÐһЩVBAÓïÑÔѵÁ·£¬¿ÉÒÔ°ïÖúÄã¸üºÃµØÀí½âVBAÓï·¨¡£Èç¹ûÄ㻨Щʱ¼äÔÚÁ¢¼´´°¡¡
¿Ú¹ýÒ»±éÕâЩÓ﷨ѵÁ·£¬Ä㽫Àí½â¾ø´ó²¿·Ö¡£¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
ͼ2£­25¡¡Excel¶ÔÏóÄ£ÐÍÀïµÄRange¶ÔÏó¡¡¡¡

25¡¡µç×Ó±í¸ñµ¥Ôª¸ñ²Ù×÷¡¡¡¡

µ±ÄãÒѾ­×¼±¸ºÃ±àдÄã×Ô¼ºµÄVBA¹ý³Ì£¬½«µç×Ó±í¸ñÈÎÎñ×Ô¶¯»¯µÄʱºò£¬ÄãºÜ¿ÉÄÜÊÇ´ÓÑ°Çó²Ù×÷µç¡¡
×Ó±í¸ñµ¥Ôª¸ñµÄÖ¸ÁʼµÄ¡£ÄãÐèÒªÖªµÀÈçºÎÑ¡Ôñµ¥Ôª¸ñ£¬Èç¹ûÔÚµ¥Ôª¸ñÊäÈëÊý¾Ý£¬ÈçºÎ¸øµ¥Ôª¸ñ¡¡
ÇøÓòÃüÃû£¬ÈçºÎÉèÖõ¥Ôª¸ñ¸ñʽ£¬ÒÔ¼°ÈçºÎÒƶ¯£¬¸´ÖƺÍɾ³ýµ¥Ôª¸ñ¡£ËäÈ»ÕâЩÈÎÎñ¿ÉÒÔͨ¹ýÊó±ê¡¡
»ò¼üÅÌÇáÒ×Ö´ÐУ¬ÕÆÎÕVBAÕâЩ·½ÃæµÄ¼¼ÊõÐèҪһЩÁ·Ï°¡£Äã±ØÐëʹÓÃRange¶ÔÏóÀ´ÒýÓõ¥¸öµ¥Ôª¸ñ£¬¡¡
µ¥Ôª¸ñÇøÓò£¬ÐлòÁС£Èç¹ûÄã¿´ÁËExcel¶ÔÏóÄ£ÐÍ£¬Äã»á×¢Òâµ½Range¶ÔÏóÊÇÁíÍâÒ»¸ö´ó¶ÔÏ󡪡ª¡¡
Worksheet¶ÔÏ󡪡ªµÄÒ»²¿·Ö¡£ÓÐÈýÖÖÊôÐÔÈÃÄã·ÃÎÊRange¶ÔÏó£ºRangeÊôÐÔ£¬CellsÊôÐÔºÍOffset¡¡
ÊôÐÔ¡£¡¡¡¡

26¡¡Ê¹Óá¡Range¡¡ÊôÐÔ¡¡¡¡

RangeÊôÐÔ·µ»ØÒ»¸öµ¥Ôª¸ñ»òÕßµ¥Ôª¸ñÇøÓò¡£ÒýÓñØÐëÊÇA1ÔÚÒýºÅÀïµÄÑùʽ£¨ÀýÈ磺¡±A1¡±£©ÒýÓá¡
¿ÉÒÔ°üÀ¨ÇøÓòÔËËã·ûðºÅ£¨ÀýÈ磺¡±A1£ºB2¡±£©»òÕßÁªºÏÔËËã·û¶ººÅ£¨ÀýÈ磺¡±A¡±£»¡±B12¡±£©¡¡¡¡
VBA²Ù×÷¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Á¢¼´´°¿ÚÊäÈë¡¡¡¡
Ñ¡Ôñµ¥¸öµ¥Ôª¸ñ£¨ÀýÈçA5£©¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Range£¨¡¨A5¡¨£©¡£Select¡¡¡¡
Ñ¡ÔñÒ»¸öµ¥Ôª¸ñÇøÓò£¨ÀýÈçA6£ºA10£©¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Range£¨¡¨A6£ºA10¡¨£©¡£Select¡¡¡¡
Ñ¡ÔñһЩ²»ÏàÁڵĵ¥Ôª¸ñ£¨ÀýÈçA1£»¡¡B6£»¡¡C8£©¡¡¡¡Range£¨¡¨A1£»¡¡B6£»¡¡C8¡¨£©¡£Select¡¡¡¡
Ñ¡ÔñһЩ²»ÏàÁڵĵ¥Ôª¸ñºÍµ¥Ôª¸ñÇøÓò£¨ÀýÈç¡¡¡¡¡¡¡¡¡¡Range£¨¡¨A11£ºD11£»¡¡C12£»¡¡D3¡¨£©¡£Select¡¡¡¡
A11£ºD11£»¡¡C12£»¡¡D3£©¡¡¡¡
¡¡¡¡

27¡¡Ê¹Óá¡Cells¡¡ÊôÐÔ¡¡¡¡

µ±ÄãҪѡÔñÒ»¸öÈ·¶¨µÄµ¥Ôª¸ñʱ£¬CellsÊôÐÔÒªÇóÁ½¸ö×Ô±äÁ¿£¬µÚÒ»¸öÊÇÐкţ¬µÚ¶þ¸öÊÇÁкŻòÕß¡¡
ÁÐ×Öĸ¡£×Ô±äÁ¿ÊäÈëÔÚÀ¨ºÅÖС£Èç¹ûºöÂÔ×Ô±äÁ¿£¬Excel½«»áÑ¡Ôñµ±Ç°¹¤×÷±íµÄËùÓе¥Ôª¸ñ¡£¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡62¡¡

¡­¡¡Ò³Ãæ¡¡79¡­

VBA²Ù×÷¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Á¢¼´´°¿ÚÊäÈë¡¡¡¡
Ñ¡Ôñµ¥¸öµ¥Ôª¸ñ£¨ÀýÈçA5£©¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Cells£¨5£»¡¡1£©¡£Select»òCells£¨5£»¡¡A£©¡£Select¡¡¡¡
Ñ¡ÔñÒ»¸öµ¥Ôª¸ñÇøÓò£¨ÀýÈçA6£ºA10£©¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Range£¨Cells£¨6£»¡¡1£©£»¡¡Cells£¨10£»¡¡1£©£©¡£Select¡¡¡¡
Ñ¡Ôñ¹¤×÷±íÖÐËùÓе¥Ôª¸ñ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Cells¡£Select¡¡¡¡
¡¡¡¡
×¢Ò⣬ÔÚÉÏÃæµÄÀý×ÓÖУ¬ÄãÈçºÎ½áºÏʹÓÃRangeºÍCellsÊôÐÔ£º¡¡¡¡
¡¡¡¡¡¡¡¡Range£¨Cells£¨6£»¡¡1£©£»¡¡Cells£¨10£»¡¡1£©£©¡£Select¡¡¡¡
ÔÚÉÏÃæµÄÀý×ÓÀµÚÒ»¸öCellsÊôÐÔ·µ»Øµ¥Ôª¸ñA6£¬¶øµÚ¶þ¸ö·µ»Øµ¥Ôª¸ñA10¡£CellsÊôÐÔ·µ»ØµÄµ¥¡¡
Ôª¸ñÖ®ºóÓÖµ±×öRange¶ÔÏóµÄ²ÎÊý¡£½á¹ûExcel¾ÍÑ¡ÔñÁËÉÏÃæµ¥Ôª¸ñΪµÚÒ»¸öCellsÊôÐÔ·µ»ØµÄ½á¹û¡¡
ºÍÏÂÃæΪµÚ¶þ¸öCellsÊôÐÔ·µ»Øµ¥Ôª¸ñµÄÇøÓòÁË¡£¡¡¡¡
¹¤×÷±íÊǵ¥Ôª¸ñµÄ¼¯ºÏ£¬ÄãÒ²¿ÉÒÔʹÓÃÖ»´øÒ»¸ö×Ô±äÁ¿µÄCellsÊôÐÔÀ´±íʾµ¥Ôª¸ñÔÚ¹¤×÷±íËùÓе¥¡¡
Ôª¼¯ºÏÖеÄλÖá£Excel°´ÏÂÁз½Ê½¸øµ¥Ôª¸ñ±àºÅ£ºµ¥Ôª¸ñA1Êǹ¤×÷±íÖеĵÚÒ»¸öµ¥Ôª¸ñ£¬B1Êǵڡ¡
¶þ¸ö£¬C1ÊǵÚÈý¸ö£¬µÈµÈ¡£Cell256ÊǵÚÒ»ÐÐÖеÄ×îºóÒ»¸öµ¥Ôª¸ñ¡£ÄãÒ²Ðí»áÏëÆðExcelÖ»ÓÐ256ÁС£¡¡¡¡
VBA²Ù×÷¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Á¢¼´´°¿ÚÊäÈ

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

Äã¿ÉÄÜϲ»¶µÄ