您好,欢迎访问三七文档
ÎÒÃÇÐèÒª°Ñ¶à¸öexcel±í¶¼·ÅÔÚͬһ¸öÎļþ¼ÐÀïÃ棬²¢ÔÚÕâ¸öÎļþ¼ÐÀïÃæн¨Ò»¸öexcel¡£ÓÃmicrosoftexcel´ò¿ªÐ½¨µÄexcel±í£¬²¢ÓÒ¼üµ¥»÷sheet1£¬ÕÒµ½¡°²é¿´´úÂ롱£¬µ¥»÷½øÈ¥¡£½øÈ¥Ö®ºó¾Í¿´µ½Á˺ê¼ÆËã½çÃ档ȻºóÎÒÃÇ°ÑÏÂÃæÕâЩºê¼ÆËãµÄ´úÂ븴ÖƽøÈ¥£¬È»ºóÕÒµ½¹¤¾ßÀ¸ÉÏÃæµÄ¡°ÔËÐС±Ïµġ°ÔËÐÐ×Ó¹ý³Ì/Óû§´°Ì塱£¬´úÂëÈçÏ£¬SubºÏ²¢µ±Ç°Ä¿Â¼ÏÂËùÓй¤×÷²¾µÄÈ«²¿¹¤×÷±í()DimMyPath,MyName,AWbNameDimWbAsWorkbook,WbNAsStringDimGAsLongDimNumAsLongDimBOXAsStringApplication.ScreenUpdating=FalseMyPath=ActiveWorkbook.PathMyName=Dir(MyPath&\&*.xls)AWbName=ActiveWorkbook.NameNum=0DoWhileMyNameIfMyNameAWbNameThenSetWb=Workbooks.Open(MyPath&\&MyName)Num=Num+1WithWorkbooks(1).ActiveSheet.Cells(.Range(B65536).End(xlUp).Row+2,1)=Left(MyName,Len(MyName)-4)ForG=1ToSheets.CountWb.Sheets(G).UsedRange.Copy.Cells(.Range(B65536).End(xlUp).Row+1,1)NextWbN=WbN&Chr(13)&Wb.NameWb.CloseFalseEndWithEndIfMyName=DirLoopRange(B1).SelectApplication.ScreenUpdating=TrueMsgBox¹²ºÏ²¢ÁË&Num&¸ö¹¤×÷±¡ÏµÄÈ«²¿¹¤×÷±í¡£ÈçÏ£º&Chr(13)&WbN,vbInformation,ÌáʾEndSub
本文标题:合并表格宏代码
链接地址:https://www.777doc.com/doc-5130510 .html