我需要在索引3提示的最后一页上循环并运行代码。我试过这样的事,但它没有用。
If (ws.sheetIndex > 2) Then
With ws
'code goes here
End With
End If
我进行了搜索,但没有找到解决此问题的方法。非常感谢帮助。
我也尝试过:
Dim i As Long, lr As Long
Dim ws As Worksheet
Windows("Book1").Activate
With ActiveWorkbook
Set ws = .Worksheets("index")
For i = 3 To 10
'code goes here
Next i
End With
答案 0 :(得分:1)
尝试使用名称
排除第一张和第二张Public Sub Sheets3andUp()
Dim ws As Worksheet
Dim nameOfSheet1 As String
Dim nameOfSheet2 As String
nameOfSheet1 = "Sheet1"
nameOfSheet2 = "Sheet2"
For Each ws In ActiveWorkbook.Worksheets
If ws.Name <> nameOfSheet1 And ws.Name <> nameOfSheet2 Then
'Code goes here
Debug.Print ws.Name
End If
Next ws
End Sub