|
3#
楼主 |
发表于 2007-4-3 21:55:00
|
只看该作者
Private Sub 导入辅助帐_Click()
'关闭系统提示
Application.DisplayAlerts = False
'汇总表机构之间循环
name1 = ThisWorkbook.Name
pathfzz = ThisWorkbook.Path & "\基层报表"
For i = 7 To 45
branch = ThisWorkbook.Worksheets("模版").Cells(i, 1)
fzz = pathfzz & "\" & branch & ".xls"
If Dir(fzz) = "" Then
MsgBox ("基层报表" & branch & " 不存在")
Else
Workbooks.Open Filename:=fzz '打开分支机构表
name2 = branch & ".xls"
Windows(name2).Activate '激活分支机构表窗口
Cells.Select '选择全表
Selection.Copy '复制
Windows(name1).Activate '激活汇总表窗口
Sheets(Trim(branch)).Select '选择对应的分支机构表
Range("A1").Select '选择第一个单元格
ActiveSheet.Paste '整表粘贴
Application.CutCopyMode = False '清空剪贴板
Range("A1").Select '去掉选择区域
Windows(name2).Activate '选择分支机构表窗口
Range("A1").Select '去掉选择区域
Application.CutCopyMode = False '清空剪贴板
' On Error Resume Next '忽略代码运行中的错误,并越过错误继续执行后面的语句
Workbooks(name2).Close False '关闭分支机构表
Windows(name1).Activate
ThisWorkbook.Worksheets("模版").Cells(i, 3) = "●"
End If
Next i
Sheets("模版").Select
'打开系统提示
Application.DisplayAlerts = True
End Sub
'我选择单元格了,但还是不行,请高手帮我看看哪写错了 |
|