excel VBA总是提示错误9 下标越界
SubImport5()Worksheets("Fina").Range("M2")=5Worksheets("Fina2").Range("G32")=1Dimshee...
Sub Import5()
Worksheets("Fina").Range("M2") = 5
Worksheets("Fina2").Range("G32") = 1
Dim sheetname
sheetname = ActiveWorkbook.Name
For I = 1 To 5
Workbooks.Open (ThisWorkbook.Path & "/" & I & ".xls")
Next
For I = 1 To 5
''on error GoTo ErrMsg
Windows(I & ".xls").Activate
Sheets("W").Select
Cells.Select
Selection.Copy
Windows(sheetname).Activate
Sheets(I).Activate
Range("A1").Activate
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Windows(I & ".xls").Close savechanges:=False 展开
Worksheets("Fina").Range("M2") = 5
Worksheets("Fina2").Range("G32") = 1
Dim sheetname
sheetname = ActiveWorkbook.Name
For I = 1 To 5
Workbooks.Open (ThisWorkbook.Path & "/" & I & ".xls")
Next
For I = 1 To 5
''on error GoTo ErrMsg
Windows(I & ".xls").Activate
Sheets("W").Select
Cells.Select
Selection.Copy
Windows(sheetname).Activate
Sheets(I).Activate
Range("A1").Activate
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Windows(I & ".xls").Close savechanges:=False 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询