VBA文件之间复制

2021-11-04 社会 136阅读
'把下面代码放入targe表中运行。
SubABCD()
DimljAsString
DimdirnameAsString
DimnmAsString
lj=ActiveWorkbook.Path
nm=ActiveWorkbook.Name
dirname=Dir(lj&"\*.xls")
Cells.Clear
DoWhiledirname<>""
Ifdirname<>nmThen
Filename=lj&"\"&dirname
SetWb=GetObject(Filename)
Workbooks(nm).Activate
Workbooks(dirname).Sheets(1).Columns("A").Copy
x=Sheets("sheet1").UsedRange.Columns.Count
x=x+Sheets("sheet1").UsedRange.Column-1
Columns(x+1).Select
ActiveSheet.Paste
Application.CutCopyMode=False
Workbooks(dirname).CloseFalse
EndIf
dirname=Dir
Loop
EndSub
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com