我有代码,用相应的负责人识别填充的标签,然后将它们打印为一个文件:
Sub printS()
Dim sht As Worksheet
For Each sht In ThisWorkbook.Worksheets
With sht
If Not IsError(Application.Match("Person1", .Range("C:C"), 0)) And .Index > 3 And Not IsEmpty(.Cells(13, 1)) Then
sht.Tab.ColorIndex = 7
sht.Select (False)
End If
End With
Next
ActiveWindow.SelectedSheets.PrintOut
End Sub
问题是Excel包含选项卡,宏按钮位于选项中。结果我在每个PDF的开头都得到了空白页。有没有办法通过更正现有代码从选项卡选择中删除带有宏按钮的选项卡?
谢谢。
答案 0 :(得分:0)
一种方法是循环内的If语句控件。
Sub printS()
Dim sht As Worksheet
For Each sht In ThisWorkbook.Worksheets
With sht
If .name <> sheets("THAT SHEET NAME HERE").name then 'this control will exclude your button sheet
If Not IsError(Application.Match("Person1", .Range("C:C"), 0)) And .Index > 3 And Not IsEmpty(.Cells(13, 1)) Then
sht.Tab.ColorIndex = 7
sht.Select (False)
End If
End if 'close block if
End With
Next
ActiveWindow.SelectedSheets.PrintOut
End Sub