Excel中要删除A行中的VBA代码是什么:对于工作簿中的所有工作表,如果值大于1,则
我已经在一个运行的宏中列出了下面列出的代码,有人可以帮我写这个集合添加到我的吗?
Sub BOMUpload_Formating()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Columns("A:A").EntireColumn.Delete
ws.Rows("1:5").EntireRow.Delete
ws.Columns("C:F").EntireColumn.Delete
ws.Columns("E:M").EntireColumn.Delete
Next ws
End Sub
谢谢, 布洛克
答案 0 :(得分:1)
Sub Button1_Click()
Dim LstRw As Long, sh As Worksheet, x
Application.ScreenUpdating = 0
For Each sh In Sheets
With sh
LstRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For x = LstRow To 2 Step -1
If .Cells(x, 1) > 1 Then
.Cells(x, 1).EntireRow.Delete
End If
Next x
End With
Next sh
End Sub
答案 1 :(得分:0)
怎么样:
Sub RowKiller()
Dim v As Variant, N As Long, i As Long, rKill As Range
Dim ws As Worksheet
For Each ws In Sheets
N = ws.Cells(Rows.Count, "A").End(xlUp).Row
If N > 1 Then
Set rKill = Nothing
For i = 1 To N
v = ws.Cells(i, 1).Value
If IsNumeric(v) Then
If v > 1 Then
If rKill Is Nothing Then
Set rKill = ws.Cells(i, "A")
Else
Set rKill = Union(rKill, ws.Cells(i, "A"))
End If
End If
End If
Next i
End If
If Not rKill Is Nothing Then rKill.EntireRow.Delete
Next ws
End Sub