我需要帮助才能在我的Excel工作表中使用一个主MACRO VBA代码
来实现以下目标如果列A包含0 - 删除整行。 (Row Killer) - 这应该在工作簿中的所有工作表上运行
由于excel文件链接严重 - 所有字段都需要转换为值(例如,粘贴为值)
以.xls格式保存AS文件,文件名为SAMAmonthlyReport
我有来自这个网站的第2点和第3点的代码,但在添加1点时需要帮助。
以下是代码
Sub CopyValuesToSync()
Dim OrigWkbkFpth As String
Dim OrigWkbk As String
Dim ValueWkbk As String
Dim WS As Worksheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False
OrigWkbkFpth = Application.ActiveWorkbook.FullName
OrigWkbk = Application.ActiveWorkbook.Name
For Each WS In ActiveWorkbook.Worksheets
WS.Select
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("A1").Select
Next WS
ActiveWorkbook.SaveAs Filename:="C:\SAMA\SamaMonthly.xls", _
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
ValueWkbk = Application.ActiveWorkbook.Name
Workbooks.Open Filename:=OrigWkbkFpth
Windows(ValueWkbk).Activate
ActiveWindow.Close
Windows(OrigWkbk).Activate
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
答案 0 :(得分:0)
您可以使用If cells(oRow,1).Value = 0 Then
之类的内容为A列中的每个单元格添加验证,然后您可以删除
Rows(oRow).EntireRow.Delete