我正在尝试将第二张工作表从工作簿2复制到工作簿1(我从中运行宏的打开的工作簿)。
第二张纸的名称不时更改。
该代码在名称不变的前提下复制了第二张纸。
Dim wb1 As Workbook
Set wb1 = ActiveWorkbook
Dim wb2 As Workbook
folder = Application.GetOpenFilename("Excel.xlsx (*.xlsx), *.xlsx," & "Excel.xls (*xls), *xls", 1, "select wb2")
Set wb2= Workbooks.Open(Filename:=folder)
Sheets("2nd sheet").Copy After:=wb1.Sheets(1)
ActiveSheet.Name = "renamed sheet 2"
wb2.Close SaveChanges:=False
我试图在复制前重命名wb2的第二张纸,但这没用。
'wb2.Sheets(2).Select
'ActiveSheet.Name = "2nd sheet"
答案 0 :(得分:2)
我可能无法正确理解您的问题,但是如果第二张纸的名称易于更改,但始终是您要复制的第二张纸,则可以通过以下方式实现:
Dim wb1 As Workbook: Set wb1 = ThisWorkbook
Dim wb2 As Workbook
Path = Application.GetOpenFilename("Excel.xlsx (*.xlsx), *.xlsx," & "Excel.xls (*xls), *xls", 1, "select wb2")
Set wb2 = Workbooks.Open(fileName:=Path)
wb2.Sheets(2).Copy After:=wb1.Sheets(1)
ActiveSheet.Name = "renamed sheet 2"
wb2.Close SaveChanges:=False
答案 1 :(得分:1)
将inputs: FormControl[] = [];
ngOnInit() {
this.myService.getNumberOfInputs().subscribe(count => {
for (let i = 0; i < count; i++) {
this.inputs.push(new FormControl(''));
}
});
}
作为其Excel工作表名称(例如<input type="text" *ngFor="let input of inputs" [formControl]="input">
)。