|
- function 人力汇总(){
- ChDrive(ThisWorkbook.Path);
- ChDir(ThisWorkbook.Path);
-
- let fname=Application.GetOpenFilename(...["Excel文件(*.xlsx)","*.xls*",,,true]);
- if (fname==false){
- alert("未选择任何工作簿。");
- return;
- }
-
- let sh=ThisWorkbook.Sheets.Item("系数表");
- let c1=sh.Range("a2").End(xlToRight).Column
- let xsarr=Range("a2").Resize(1,c1).Value2;
- let obj=new Object();
- for (let [i,v] of xsarr[0].entries()){
- obj[WorksheetFunction.Text(v,"yyyymm")]=i;
- }
-
- Application.DisplayAlerts=false;
- for (let f of fname){
- Workbooks.Open(f);
- let xmarr=ActiveSheet.Range("b9:i9").Value2[0];
- let temparr=[xmarr[1],xmarr[0],xmarr[2],xmarr[3],xmarr[4],xmarr[6],xmarr[7]];
-
- temparr.length=xsarr[0].length;
-
- let c2=ActiveSheet.Cells(11,Columns.Count).End(xlToLeft).Column;
- let r1=ActiveSheet.Cells(Rows.Count,3).End(xlUp).Row;
- let btarr=ActiveSheet.Cells(11,1).Resize(1,c2).Value2[0];
- let sjarr=ActiveSheet.Cells(r1,1).Resize(1,c2).Value2[0];
-
- for (let [i,v] of btarr.entries()){
- let bt=WorksheetFunction.Text(v,"yyyymm");
- if (bt in obj){
- n=obj[bt];
- temparr[n]=sjarr[i];
- }
- }
- xsarr.push(temparr);
- ActiveWorkbook.Close(false);
- }
- if (xsarr.length>1){
- sh.Range("a2").Resize(xsarr.length,xsarr[0].length).Value2=xsarr;
- }
- Application.DisplayAlerts=true;
- }
复制代码 |
|