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

µÚ23²¿·Ö

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

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

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



ÇøÓòÃüÃû£¬ÈçºÎÉèÖõ¥Ôª¸ñ¸ñʽ£¬ÒÔ¼°ÈçºÎÒƶ¯£¬¸´ÖƺÍɾ³ýµ¥Ôª¸ñ¡£ËäÈ»ÕâЩÈÎÎñ¿ÉÒÔͨ¹ýÊó±ê¡¡
»ò¼üÅÌÇáÒ×Ö´ÐУ¬ÕÆÎÕ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²Ù×÷¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Á¢¼´´°¿ÚÊäÈë¡¡¡¡
Ñ¡Ôñµ¥Ôª¸ñA1¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Cells£¨1£©¡£Select¡¡or¡¡Cells¡£Item£¨1£©¡£Select¡¡¡¡
Ñ¡Ôñµ¥Ôª¸ñC1¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Cells£¨3£©¡£Select¡¡or¡¡Cells¡£Item£¨3£©¡£Select¡¡¡¡
Ñ¡Ôñµ¥Ôª¸ñIV1¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Cells£¨256£©¡£Select¡¡or¡¡Cells¡£Item£¨256£©¡£Select¡¡¡¡
Ñ¡Ôñµ¥Ôª¸ñA2¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Cells£¨257£©¡£Select¡¡or¡¡Cells¡£Item£¨257£©¡£Select¡¡¡¡
¡¡¡¡
×¢Ò⣬ItemÊÇ·µ»ØÒ»¸ö¼¯ºÏ³ÉÔ±µÄÊôÐÔ¡£ÒòΪItemÊÇÒ»¸ö¼¯ºÏµÄĬÈϳÉÔ±£¬Äã¿ÉÒÔÖ±½ÓÒýÓù¤×÷±í¡¡
µ¥Ôª¸ñ£¬¶ø²»±ØÃ÷È·µØʹÓÃItemÊôÐÔ¡£¡¡¡¡
ÏÖÔÚÄã·¢ÏÖÁËÁ½ÖÖ·½·¨Ñ¡Ôñµ¥Ôª¸ñ£¨RangeÊôÐÔºÍCellsÊôÐÔ£©£¬ÄãÒ²ÐíºÜÃÔ»óΪʲôҪʹÓøü¸´ÔÓ¡¡
µÄCellsÊôÐÔÄØ£¿ºÜÃ÷ÏÔRangeÊôÐÔ¸ü¾ßÓпɶÁÐÔ£¬±Ï¾¹£¬ÄãÔ¶ÔÚ¾ö¶¨Ñ§Ï°VBA֮ǰ¾ÍÔÚExcel¹«Ê½ºÍ¡¡
º¯ÊýÀïÃæʹÓÃÁËRangeÒýÓá£È»¶ø£¬µ±ÐèÒª½«µ¥Ôª¸ñµ±×ö¼¯ºÏ²Ù×÷µÄʱºò£¬CellsÊôÐÔÔòʹÓøü·½±ã¡£¡¡
ʹÓÃÕâ¸öÊôÐÔÈ¥·ÃÎʵ¥Ôª¸ñ¼¯ºÏÖеÄËùÓе¥Ôª¸ñ»òÕßµ¥¸öµ¥Ôª¸ñ¡£¡¡¡¡

28¡¡Ê¹Óá¡Offset¡¡ÊôÐÔ¡¡¡¡

ÁíÍâÒ»¸öÒýÓù¤×÷±íµ¥Ôª¸ñ·Ç³£Áé»îµÄ·½·¨ÊÇʹÓÃOffsetÊôÐÔ¡£µ±¹¤×÷±íÈÎÎñ×Ô¶¯»¯Ê±£¬ÄãÒ²Ðí²»¡¡
ÖªµÀij¸öµ¥Ôª¸ñµÄÈ·ÇеØÖ·¡£ÄãÈçºÎÄܹ»Ñ¡ÔñÒ»¸öÄã¸ù±¾²»ÖªµÀµØÖ·µÄµ¥Ôª¸ñ£¿Äã¿ÉÒÔÈÃExcel»ù¡¡
ÓÚµ±Ç°Ñ¡ÔñµÄµ¥Ôª¸ñÀ´Ñ¡ÔñÒ»¸öλÖá£OffsetÊôÐÔͨ¹ý¼ÆËã´Ó¿ªÊ¼Ñ¡ÔñµÄµ¥Ôª¸ñÏòÏ»òÏòÉÏÒƶ¯µÄ¡¡
¾ßÌåÐÐÊý£¬À´µÃµ½ÐµÄÇøÓò¡£Í¬ÑùÒ²¿ÉÒÔ´Óµ±Ç°Ñ¡ÔñµÄµ¥Ôª¸ñÇøÓòÏòÓÒ»òÏò×óÒƶ¯¾ßÌåµÄÁÐÊý¡£¡¡
OffsetÊôÐÔʹÓÃÁ½¸ö×Ô±äÁ¿À´»ñµÃе¥Ôª¸ñÇøÓòµÄµØÖ·¡£µÚÒ»¸ö×Ô±äÁ¿±íʾÐÐÆ«ÒÆ£¬µÚ¶þ¸ö×Ô±äÁ¿¡¡
Ôò±íʾÁÐÆ«ÒÆ¡£ÎÒÃÇÀ´²âÊÔһϼ¸¸öÀý×Ó£º¡¡¡¡
VBA²Ù×÷¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Á¢¼´´°¿ÚÊäÈë¡¡¡¡
Ñ¡Ôñµ¥Ôª¸ñA1ÏÂÃæÒ»ÐкÍÓÒ±ßÈýÁеĵ¥Ôª¸ñ¡¡¡¡¡¡¡¡¡¡¡¡Range£¨¡¨A1¡¨£©¡£Offset£¨1£»¡¡3£©¡£Select¡¡¡¡
Ñ¡Ôñµ¥Ôª¸ñD15ÉÏÃæÁ½ÐкÍ×ó±ßÒ»Áеĵ¥Ôª¸ñ¡¡¡¡¡¡¡¡¡¡Range£¨¡¨D15¡¨£©¡£Offset£¨¡­2£»¡¡¡­1£©¡£Select¡¡¡¡
Ñ¡Ôñµ±Ç°µ¥Ôª¸ñÉÏÃæÒ»Ðеĵ¥Ôª¸ñ£¨Í¬ÁУ©¡¡¡¡¡¡¡¡¡¡¡¡ActiveCell¡£Offset£¨¡­1£»¡¡0£©¡£Select¡¡¡¡
¡¡¡¡
ÉÏÃæµÄµÚÒ»¸öÀý×ÓÀExcelÑ¡ÔñµÄʱµ¥Ôª¸ñD2¡£Ò»µ©ÄãÊäÈëÁ˵ڶþ¸öÀý×Ó£¬ExcelÑ¡ÔñÁ˵¥Ôª¸ñC13¡£¡¡¡¡
Èç¹ûµ¥Ôª¸ñA1ºÍD15ÒѾ­±»Ñ¡ÖÐÁË£¬ÄãÒ²¿ÉÒÔ½«ÉÏÃæµÄÁ½¸öÀý×Ó¸ÄдΪÕâÑù£º¡¡¡¡
¡¡¡¡¡¡¡¡Selection¡£Offset£¨1£»¡¡3£©¡£Select¡¡¡¡¡¡
¡¡¡¡¡¡¡¡Selection¡£Offset£¨¡­2£»¡¡¡­1£©¡£Select¡¡¡¡
×¢Ò⣬ÉÏÃæµÚÈý¸öÀý×ÓÀïµÄµÚ¶þ¸ö×Ô±äÁ¿ÊÇ0£¬µÚÒ»¸ö»òµÚ¶þ¸ö×Ô±äÁ¿Îª0ʱ£¬OffsetÊôÐÔÏàÓ¦±íʾ¡¡
µ±Ç°Ðлòµ±Ç°ÁС£Èç¹ûµ±Ç°»î¶¯µ¥Ôª¸ñÔÚµÚÒ»ÐУ¬ÄÇôָÁîActiveCell¡£Offset£¨¡­1£»¡¡0£©¡£Select»á¡¡
µ¼Ö´íÎ󡣡¡¡¡
µ±Ê¹ÓÃOffsetÊôÐÔʱ£¬Äã¿ÉÄÜÓÐʱÐèÒª¸Ä±äÑ¡ÔñÇøÓòµÄ´óС¡£¼ÙÉ迪ʼѡÔñµÄÇøÓòÊÇA5£ºA10£¬ÈçºÎ¡¡
½«Ñ¡ÔñÇøÓòÏòÏÂÒƶ¯Á½ÐУ¬ÏòÓÒÒƶ¯Á½ÁУ¬È»ºóÔٸıäÐÂÑ¡ÔñÇøÓòµÄ´óСÄØ£¿¼ÙÉèеÄÑ¡ÔñÇøÓòÓ¦¡¡
¸ÃÊÇC7£ºC8¡£OffestÊôÐÔÖ»ÄÜÍê³ÉÇ°Ã沿·Ö£¬ºóÃ沿·ÖÒªÇóÁíÍâÒ»¸öÊôÐÔÀ´Íê³É¡£ExcelÓиöרÃŵġ¡
ResizeÊôÐÔ£¬Äã¿ÉÒÔ½áºÏOffsetÊôÐÔºÍResizeÊôÐÔÀ´»Øµ½ÉÏÃæµÄÎÊÌâ¡£ÔÚÄã½áºÏÕâÁ½¸öÊôÐÔ֮ǰ£¬¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡63¡¡

¡­¡¡Ò³Ãæ¡¡80¡­

ÎÒÃÇÏÈÀ´¿´¿´ÈçºÎ¶ÀÁ¢µØʹÓÃËüÃÇ£º¡¡¡¡
1¡£¡¡¡¡½«Excel´°¿ÚºÍVB´°¿Ú²¢ÅÅÏÔʾ¡¡¡¡
2¡£¡¡¡¡¼¤»îÁ¢¼´´°¿Ú£¬²¢ÇÒÊäÈëÏÂÊöÖ¸Á¡¡¡¡
¡¡¡¡¡¡¡¡Range£¨¡¨A5£ºA10¡¨£©¡£Select¡¡¡¡¡¡
¡¡¡¡¡¡¡¡Selection¡£Offset£¨2£»¡¡2£©¡£Select¡¡¡¡¡¡
¡¡¡¡¡¡¡¡Selection¡£Resize£¨2£»¡¡4£©¡£Select¡¡¡¡
ÉÏÃæµÄµÚÒ»ÌõÖ¸ÁîÑ¡ÔñÇøÓòA5£ºA10£¬µ±Ç°»î¶¯µ¥Ôª¸ñÊÇA5¡£µÚ¶þÌõÖ¸ÁѡÇøÆ«ÒƵ½C7£ºC12¡£µ¥Ôª¡¡
¸ñC7´¦Óڻµ¥Ôª¸ñA5µÄÏòÏÂÁ½ÐкÍÏòÓÒÁ½ÁС£ÏÖÔÚ£¬»î¶¯µ¥Ôª¸ñÊÇC7¡£×îºóÒ»ÌõÖ¸Áµ±Ç°Ñ¡Çø¡¡
¸Ä±ä´óС£¬µ¥Ôª¸ñÇøÓòC7£ºC8±»Ñ¡ÖÐÁË£¬¶ø²»ÔÙÊÇC7£ºC12¡£ÏóOffsetÊôÐÔÒ»Ñù£¬ResizeÊôÐÔÒ²ÐèÒª¡¡
Á½¸ö×Ô±äÁ¿¡£µÚÒ»¸öÊÇÄãҪѡȡµÄÐÐÊý£¬µÚ¶þ¸öÔòÊÇҪѡȡµÄ¾ßÌåÁÐÊýÒò´Ë£¬Ö¸Áî¡¡
Selection¡£Resize£¨2£»¡¡4£©¡£Select½«µ±Ç°Ñ¡ÔñÇøÓò¸ÄΪÁ½ÐкÍËÄÁС¡¡¡
ºóÃæÁ½ÐÐÖ¸Áî¿ÉÒÔ½áºÏ³ÉÏÂÃ淽ʽ£º¡¡¡¡
¡¡¡¡¡¡¡¡Selection¡£Offset£¨2£»¡¡2£©¡£Resize£¨2£»¡¡4£©¡£Select¡¡¡¡
ÉÏÃæµÄÀý×Ó£¬ÏÈÊÇOffsetÊôÐÔ¼ÆËãµÃµ½ÐÂÇøÓòµÄÆðʼµã£¨ÒëÕߣºÑ¡Çø×óÉϽǵĵ¥Ôª¸ñ£©£¬½Ó×ÅÊÇResize¡¡
ÊôÐÔ¾ö¶¨ÐÂÑ¡ÇøµÄ´óС£¬È»ºóÊÇSelect·½·¨Ñ¡È¡¾ßÌåµÄµ¥Ôª¸ñÇøÓò¡£¡¡¡¡
¼¼ÇÉ2£­6£ºÂ¼ÖƵ¥Ôª¸ñµÄÑ¡Ôñ¡¡¡¡
ºê¼ÖÆÆ÷ĬÈϵØʹÓÃRangeÊôÐÔ¼ÖÆÑ¡Ôñµ¥Ôª¸ñ¡£Èç¹ûÄã´ò¿ªºê¼ÖÆÆ÷£¬²¢ÇÒÑ¡Ôñµ¥Ôª¸ñA2£¬ÊäÈë¡¡
¡¡¡°text¡±£¬ÔÙÑ¡Ôñµ¥Ôª¸ñA5£¬Ä㽫ÔÚVB±à¼­Æ÷´°¿ÚÀïµÃµ½ÏÂÊö´úÂ룺¡¡¡¡
Range£¨¡¨A2¡¨£©¡£Select¡¡¡¡¡¡
ActiveCell¡£FormulaR1C1¡¡=¡¡¡¨text¡¨¡¡¡¡¡¡
Range£¨¡¨A5¡¨£©¡£Select¡¡¡¡
Èç¹ûÄãʹÓÃÏà¶ÔÒýÓ÷½Ê½£¬ºê¼ÖÆÆ÷»áʹÓÃOffsetÊôÐÔ¡£Äã¿ÉÒÔÔÚ¼ÖÆÇ°£¬µã»÷ºê¼Öƹ¤¾ßÌõÉϵġ¡
Ïà¶ÔÒýÓð´Å¥¡£ºê¼ÖÆÆ÷½«µÃµ½ÈçÏ´úÂ룺¡¡¡¡
ActiveCell¡£Offset£¨¡­3£»¡¡0£©¡£Range£¨¡¨A1¡¨£©¡£Select¡¡¡¡¡¡
ActiveCell¡£FormulaR1C1¡¡=¡¡¡¨text¡¨¡¡¡¡¡¡
ActiveCell¡£Offset£¨3£»¡¡0£©¡£Range£¨¡¨A1¡¨£©¡£Select¡¡¡¡
µ±ÄãʹÓÃÏà¶ÔÒýÓ÷½Ê½Â¼Öƺêʱ£¬¹ý³Ì×ÜÊÇ»áÑ¡ÔñÏà¶ÔÓÚµ±Ç°»î¶¯µ¥Ôª¸ñµÄµ¥Ôª¸ñ¡£×¢Ò⣬ÉÏÃæÖ¸¡¡
ÁîÖеĵÚÒ»ºÍµÚÈýÐеÄÒýÓõ¥Ôª¸ñA1£¬¼´Ê¹ÎÒÃÇûÓÐÉæ¼°µ½A1µÄÈκζ«Î÷¡£Äã¿ÉÄܼǵã¬ÔÚµÚÒ»Õ¡¡
ÖУ¬ºê¼ÖÆÆ÷ÓÃËü×Ô¼ºµÄ·½Ê½½«ÊÂÇé¸ã¶¨¡£ÎªÁ˽«ÉÏÃæµÄÖ¸Áî±ä¼òµ¥Ò»Ð©£¬Äã¿ÉÒÔɾ³ý¶Ôµ¥Ôª¸ñA1¡¡
µÄÒýÓ㺡¡¡¡
ActiveCell¡£Offset£¨¡­3£»¡¡0£©¡£Select¡¡¡¡¡¡
ActiveCell¡£FormulaR1C1¡¡=¡¡¡¨text¡¨¡¡¡¡¡¡
ActiveCell¡£Offset£¨3£»¡¡0£©¡£Select¡¡¡¡
ʹÓÃÏà¶ÔÒýÓÃÀ´Â¼Öƹý³Ìºó£¬²»ÒªÍü¼ÇÔٴεã»÷Õâ¸ö°´Å¥£¬Èç¹ûϴμÖÆÒ»¸ö·ÇÏà¶ÔµØÖ·µÄ¹ý³Ì¡£¡¡¡¡

29¡¡Ñ¡Ôñµ¥Ôª¸ñµÄÆäËü·½·¨¡¡¡¡

Èç¹ûÄã¾­³£ÐèÒª·ÃÎÊÄ㹤×÷±íÀïijЩңԶµÄµ¥Ôª¸ñ£¬Äã¿ÉÄÜÒѾ­¶ÔÏÂÃæµÄ¼üÅÌ¿ì½Ý¼üºÜÊìϤ£ºEnd£«¡¡
ÉϼýÍ·£¬¡¡End£«Ï¼ýÍ·£¬¡¡End£«×ó¼ýÍ·ºÍEnd£«ÓÒ¼ýÍ·¡£ÔÚVBAÖУ¬Äã¿ÉÒÔʹÓÃEndÊôÐÔ¿ìËÙµØÒƶ¯µ½Ò£¡¡
Ô¶µÄµ¥Ôª¸ñ¡£¡¡¡¡
VBA²Ù×÷¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Á¢¼´´°¿ÚÊäÈë¡¡¡¡
Ñ¡ÔñÈκÎÐеÄ×îºóÒ»¸öµ¥Ôª¸ñ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ActiveCell¡£End£¨xlright£©¡£Select¡¡¡¡
Ñ¡ÔñÈκÎÁеÄ×îºóµ¥Ôª¸ñ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ActiveCell¡£End£¨xldown£©¡£Select¡¡¡¡
Ñ¡ÔñÈκÎÐеĵÚÒ»¸öµ¥Ôª¸ñ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ActiveCell¡£End£¨xleft£©¡£Select¡¡¡¡
Ñ¡ÔñÈκÎÁеĵÚÒ»¸öµ¥Ôª¸ñ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ActiveCell¡£End£¨xlup£©¡£Select¡¡¡¡
¡¡¡¡
×¢Ò⣬EndÊôÐÔÒªÇóÒ»¸ö×Ô±äÁ¿À´±íʾÄãÒªÒƶ¯µÄ·½Ïò¡£Ê¹ÓÃÏÂÁÐExcelÄÚÖõij£ÊýÀ´Ìøµ½¾ßÌåµÄ·½¡¡
Ïò£ºxlright£»¡¡xlleft£»¡¡xlup£»¡¡xldown¡£¡¡¡¡

30¡¡Ñ¡ÔñÐкÍÁС¡¡¡

ExcelʹÓÃEntireRowºÍEntireColumnÊôÐÔÀ´Ñ¡ÔñÕûÐлòÕûÁС£¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡64¡¡

¡­¡¡Ò³Ãæ¡¡81¡­

VBA²Ù×÷¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Á¢¼´´°¿ÚÊäÈë¡¡¡¡
Ñ¡Ôñµ±Ç°»î¶¯µ¥Ôª¸ñËùÔÚÐеÄÕûÐС¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Selection¡£EntireRow¡£Select¡¡¡¡
Ñ¡Ôñµ±Ç°»î¶¯µ¥Ôª¸ñËùÔÚÁеÄÕûÁС¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Selection¡£EntireColumn¡£Select¡¡¡¡
¡¡¡¡
ÄãÑ¡ÔñÁËÒ»¸öµ¥Ôª¸ñÇøÓò£¬ÄãÒ²ÐíÏëÒªÖªµÀÑ¡Çø°üÀ¨¶àÉÙÐУ¬¶àÉÙÁС£ÎÒÃÇÀ´ÈÃExcel¼ÆËãÇøÓò¡¡
A1£ºD15ÖеÄÐÐÊýºÍÁÐÊý£º¡¡¡¡
1¡£¡¡¡¡ÔÚÁ¢¼´´°¿ÚÀïÊäÈëÏÂÊöVBAÓï¾ä¡¡¡¡
¡¡¡¡¡¡¡¡Range£¨¡¨A1£ºD15¡¨£©¡£Select¡¡¡¡
Èç¹ûExcel´°¿Ú¿É¼û£¬µ±Äã°´»Ø³µºó£¬VBA»áÑ¡ÖÐÇøÓòA1£ºD15¡¡¡¡
2¡£¡¡¡¡ÊäÈëÏÂÁÐÓï¾äÀ´µÃµ½Ñ¡ÇøµÄÐÐÊý¡¡¡¡
¡¡¡¡¡¡¡¡£¿Selection¡£Rowsunt¡¡¡¡
Ò»µ©Äã»Ø³µ£¬VBAÔÚÏÂÒ»ÐÐÏÔʾ½á¹û¡£ÄãµÄÑ¡Ôñ°üÀ¨15ÐС¡¡¡
3¡£¡¡¡¡ÊäÈëÏÂÁÐÓï¾äÀ´µÃµ½Ñ¡ÇøµÄÁÐÊý¡¡¡¡
¡¡¡¡¡¡¡¡£¿Selectionlumnsunt¡¡¡¡
ÏÖÔÚVBA¸æËßÄ㣬ѡÖеÄÇøÓòA1£ºD15Õ¼¾ÝÁËËÄÁеĿí¶È¡£¡¡¡¡
4¡£¡¡¡¡½«¹â±ê·ÅÔڹؼü×ÖRows»òColumnsÖеÄÈÎÒâλÖ㬲¢ÇÒ°´ÏÂF1£¬»ñÈ¡ÕâЩÓÐÓÃÊôÐԵĸü¶àÐÅÏ¢¡£¡¡¡¡

31¡¡»ñÈ¡¹¤×÷±íÐÅÏ¢¡¡¡¡

Excel¹¤×÷±íÓжà´ó£¿ËüÓжàÉÙµ¥Ôª¸ñ£¬ÁкÍÐУ¿¼´Ê¹ÄãÍü¼ÇÁËÕâЩϸ½Ú£¬Ê¹ÓÃCountÊôÐÔ¡£¡¡¡¡
VBA²Ù×÷¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Á¢¼´´°¿ÚÊäÈë¡¡¡¡
¼ÆËãExcel¹¤×÷±íÀï×ܵ¥Ôª¸ñÊý¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡£¿Cellsunt¡¡¡¡
¼ÆËãExcel¹¤×÷±íÀï×ÜÐÐÊý¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡£¿Rowsunt¡¡¡¡
¼ÆËãExcel¹¤×÷±íÀï×ÜÁÐÊý¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡£¿Columnsunt¡¡¡¡
¡¡¡¡
¡¡Excel¡¡2002¹¤×÷±íÀïÓÐ16£»777216¸öµ¥Ôª¸ñ£¬65£»536ÐкÍ256ÁС£¡¡¡¡

32¡¡Íù¹¤×÷±íÊäÈëÊý¾Ý¡¡¡¡

ÊäÈ빤×÷±íÀïµÄÐÅÏ¢¿ÉÒÔÊÇÎı¾£¬Êý×Ö»òÕß¹«Ê½¡£Äã¿ÉÒÔʹÓÃRange¶ÔÏóµÄÁ½ÖÖÊôÐÔÖ®Ò»À´Íùµ¥Ôª¡¡
¸ñ»òµ¥Ôª¸ñÇøÓòÀïÊäÈëÊý¾Ý£ºValueÊôÐÔ»òÕßFormulaÊôÐÔ¡£¡¡¡¡
ValueÊôÐÔ£º¡¡¡¡
¡¡¡¡¡¡¡¡ActiveSheet¡£Range£¨¡¨A1£ºC4¡¨£©¡£Value¡¡=¡¡¡¨=4¡¡*¡¡25¡¨¡¡¡¡
FormulaÊôÐÔ£º¡¡¡¡
¡¡¡¡¡¡¡¡ActiveSheet¡£Range£¨¡¨A1£ºC4¡¨£©¡£Formula¡¡=¡¡¡¨=4¡¡*¡¡25¡¨¡¡¡¡
ÉÏÃæÁ½ÖÖÀý×Ó£¬A1µ¥Ôª¸ñ¶¼ÏÔʾ4³Ë25µÄ½á¹û100¡£¡¡¡¡
VBA²Ù×÷¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Á¢¼´´°¿ÚÊäÈë¡¡¡¡
ÔÚµ¥Ôª¸ñA5ÀïÊäÈëÎı¾¡°Amount¡¡Due¡±¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Range£¨¡¨A5¡¨£©¡£Formula¡¡=¡¡¡¨Amount¡¡Due¡¨¡¡¡¡
ÔÚµ¥Ôª¸ñD21ÀïÊäÈëÊý×Ö¡°123¡±¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Range£¨¡¨D21¡¨£©¡£Formula¡¡=¡¡123¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Range£¨¡¨D21¡¨£©¡£Value¡¡=¡¡123¡¡¡¡
ÔÚµ¥Ôª¸ñB4ÀïÊäÈ빫ʽ¡°=D21*3¡±¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Range£¨¡¨B4¡¨£©¡£Formula¡¡=¡¡¡¨=D21¡¡*¡¡3¡¨¡¡¡¡
¡¡¡¡

33¡¡·µ»Ø¹¤×÷±íÖеÄÐÅÏ¢¡¡¡¡

ºÁÎÞÒÉÎÊ£¬ÄãÔ

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

Äã¿ÉÄÜϲ»¶µÄ