标签:bsp for val range excel 工作 内容 ext span
Sub 表和格() ‘定义工作表 Dim ws As Worksheet ‘get sheet by name【看到的表名,或序号1,2,3,...】,要加Set Set ws = Worksheets("表") Set ws = Worksheets(1)
‘1,2:单元格内容(页面对应Range,坐标对应Cells) Debug.Print ws.Range("B1") Debug.Print ws.Cells(1, 1)
tmp = Cells(1, 1).Value ‘ 3:变量不用定义,当前写代码的Sheet
End Sub
Sub 遍历所有表() For Each ws In Worksheets Debug.Print ws.Name Next End Sub
Sub 遍历部分表() For i = 1 To 2 ‘i不用定义 Dim ws As Worksheet Set ws = Worksheets(i) Debug.Print ws.Name Next End Sub
标签:bsp for val range excel 工作 内容 ext span
原文地址:http://www.cnblogs.com/AndyHoo/p/6128065.html