使用排除项目运行macros多个工作表

我试图在工作簿中的多个数据表中运行这个macros,但我不能让代码跨工作簿正常运行。 如果我在一张纸上运行macros,它工作正常,但我想现在运行所有的工作表,并排除“数据”和“更新”工作表,并没有任何运气的代码是下面,如果有任何build议如何通过所有工作表正常运行? 谢谢

Sub UpdatePrices() Dim ws As Worksheet, Ldate As String, DateRng As Range Set DateRng = Range("A3") 'date range is last date Ldate = DateRng.Value 'defines ldate as most recent date For Each ws In ActiveWorkbook.Worksheets 'Inserts a new row with containing today's Date and exclude sheets If Ldate <> Date And ws.Name <> "DATA" Or ws.Name <> "UPDATE" Then DateRng.EntireRow.Insert DateRng.Offset(-1, 0) = "=TODAY()" Else End If Next ws End sub 

尝试下面的代码

 Sub UpdatePrices() Dim ws As Worksheet, Ldate As String, DateRng As Range Set DateRng = Sheets("Sheet1").Range("A3") 'date range is last date Ldate = DateRng.Value 'defines ldate as most recent date For Each ws In ThisWorkbook.Worksheets ws.Select 'Inserts a new row with containing today's Date and exclude sheets If Ldate <> Date And UCase(ws.Name) <> "DATA" And UCase(ws.Name) <> "UPDATE" Then ws.Rows(DateRng.Row).EntireRow.Insert ws.Cells(DateRng.Row, DateRng.Column).Offset(-1, 0) = "=TODAY()" End If Next End Sub