4操作工作簿
Workbooks工作簿
for each (for的另一种形式)

For Each ge In Range("a1:a10")
i = i + 1
ge = i

Next

Esc停止执行代码

打开文件Open:

Workbooks.Open Filename:="d:\data\1.xlsx"
ActiveWorkbook.Sheets(1).Range("a1") = "到此一游"

成对使用取消屏幕显示的多余的东西

Application.DisplayAlerts = False
Application.ScreenUpdating = False
...
Application.DisplayAlerts = True
Application.ScreenUpdating = True

实例: 打开文件

Sub shi()

Application.DisplayAlerts = False
Application.ScreenUpdating = False

Workbooks.Open Filename:="d:\data\1.xlsx"
ActiveWorkbook.Sheets(1).Range("a1") = "1到此一游"
ActiveWorkbook.Save
ActiveWorkbook.Close
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

Add 新建工作簿

Workbooks.Add
ActiveWorkbook.Sheets(1).Range("a1") = "创建工作簿"

ActiveWorkbook.SaveAs Filename:="d:\data\2.xlsx"
ActiveWorkbook.Close

把一个表拆分多个文件

Dim sht As Worksheet
For Each sht In Sheets
sht.Copy
ActiveWorkbook.SaveAs Filename:="d:\data\" & sht.Name & ".xlsx"
ActiveWorkbook.Close
Next

上节课的作业易错点:
先点表(Sheet(j).select),再点单元格(Sheet(j).Range("d" & i).select)