这样的代码一般可以DIR扫描文件夹,或者指定文件名,例如:
'Dir 循环
set st=activesheet
p = "c:\数据\"
n = Dir(p & "*.xls?")
while n<>""
with workbooks.open(p & n)
activesheet.usedrange.copy st.rows(rows.count,1).end(xlup).offset(1,0)
.close
end with
n=Dir
wend
或者:
'指定 循环 201901 ~ 201912
set st=activesheet
for n=1 to 12
with workbooks.open("c:\数据\2019" & format(n,"") & ".xlsx")
activesheet.usedrange.copy st.rows(rows.count,1).end(xlup).offset(1,0)
.close
end with
next n
写代码可以实现的,发文件来