'简易实现单列查找定位到最后一次出现的行
Private Sub CommandButton1_Click()
Dim arr1
cx = TextBox1.Value
arr1 = Range("C1:C10000")
For i = 1 To UBound(arr1)
If arr1(i, 1) = cx Then
n = i
End If
Next
Range("c" & n).Select
End Sub
Sub 删除A列等于指定内容的行()
Dim a As Range
endrow = Range("A65536").End(xlUp).Row
For Each a In Range("A1:A" & endrow)
If a = "指定内容" Then
a.EntireRow.Delete
End If
Next
End Sub
有个工作表,有N行N列,B列是领料部门,C列是领料用途,E列是发料仓库,凡是B列有“研发部”、“技术部”,则整行删除;
凡是C列有“检测”、“修理”、“生产”,则整行删除;凡是E列有“基建仓库”、“成品仓库”,则整行删除。
Sub Delrows()
Dim Arr, k&
Arr = [A1].CurrentRegion'把[A1]开始的当前区域的值赋给
Application.ScreenUpdating = False
For k = UBound(Arr) To 1 Step -1
If InStr(Arr(k, 2), "研发部") + InStr(Arr(k, 2), "技术部") + _
InStr(Arr(k, 3), "检测") + InStr(Arr(k, 3), "修理") + InStr(Arr(k, 3), "生产") + _
InStr(Arr(k, 5), "基建仓库") + InStr(Arr(k, 5), "成品仓库") Then
Rows(k).Delete
End If
Next
Application.ScreenUpdating = True
End Sub
Sub 计数()
Dim arr, i, j, k
i = ActiveSheet.Range("k" & Rows.Count).End(xlUp).Row
arr = Range("k5:k" & i)
For j = 1 To UBound(arr)
If arr(j, 1) = "江西岑阳" Then'查询江西岑阳出现的次数
k = k + 1
End If
Next
End Sub