打印按钮后运行宏

时间:2015-02-16 16:51:10

标签: excel vba

我们正在寻找一个宏,如果列I的值为零,用户点击打印按钮后将删除整行。它删除了一切。 http://i.imgur.com/1SVDVLi.jpg

Private Sub Workbook_BeforePrint(Cancel As Boolean)

   Sub DeleteRows()
   Dim c As Range
   Dim SrchRng

   Set SrchRng = ActiveSheet.UsedRange
   Do
       Set c = SrchRng.Find("0", LookIn:=xlValues)
       If Not c Is Nothing Then c.EntireRow.Delete
   Loop While Not c Is Nothing
End Sub

0 个答案:

没有答案