|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
JSA代码参与下
- function 工作簿拆分(){
- let bt=Range("a1").CurrentRegion.Value2[0];
- let obj=bt.reduce((dic,x,i)=>(i>1 && x!=null?dic[x]=Cells(1,i+1).MergeArea.Address():null,dic),{});
- let arr=Object.values(obj),month=bt[0],path=ThisWorkbook.Path;
- for (let key in obj){
- let temp=[...arr];
- ActiveSheet.Copy();
- Range(temp.splice(arr.indexOf(obj[key]),1).join(",")).EntireColumn.Delete();
- ActiveWorkbook.SaveAs(`${path}\\${key}-${month}月.xlsx`,51);
- ActiveWorkbook.Close(false);
- }
- }
复制代码 |
|