|
|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 ykcbf1100 于 2025-12-7 21:20 编辑
- Sub ykcbf() '//2025.12.7
- ApplicationSettings False
- Set ws = ActiveSheet
- arr = ws.UsedRange.Value
- u = UBound(arr, 2)
- ReDim brr(1 To UBound(arr), 1 To UBound(arr, 2))
- ptt1 = "高2024级1班|高2024级2班|高2024级3班|高2025级1班|高2025级2班|高2025级3班|高2025级4班|高2026级1班|高2026级2班|高2026级3班|高2026级4班|教师"
- ppt2 = "有卡变更|换卡|存款|挂失|补卡|纠错"
- ptt3 = "晚餐|早餐"
- Dim tm: tm = Timer
- For i = 2 To UBound(arr)
- If styes(arr(i, 5), ptt1) = True _
- Or styes(arr(i, 11), ptt2) = True _
- Or styes(arr(i, 9), ptt3) = True Then GoTo 100
- m = m + 1
- For j = 1 To u
- brr(m, j) = arr(i, j)
- Next
- 100:
- Next
- ws.[a2].Resize(m, u) = brr
- ws.UsedRange.Offset(m + 1).Clear
- ApplicationSettings True
- MsgBox "共用时:" & Format(Timer - tm, "0.000") & " 秒"
- End Sub
- Function styes(st, ptt) As Boolean
- Dim arr() As String, i As Long
- If ptt = "" Or Trim(st & "") = "" Then Exit Function
- arr = Split(ptt, "|")
- For i = LBound(arr) To UBound(arr)
- If InStr(1, st, arr(i), vbTextCompare) > 0 Then
- styes = True
- Exit Function
- End If
- Next
- End Function
- Private Sub ApplicationSettings(ByVal Reset As Boolean) '//纯office环境
- With Application
- .ScreenUpdating = Reset: .DisplayAlerts = Reset
- .Calculation = IIf(Reset, xlCalculationAutomatic, xlCalculationManual)
- .AskToUpdateLinks = Reset: .EnableEvents = Reset: .EnableAnimations = Reset
- End With
- End Sub
复制代码
|
评分
-
2
查看全部评分
-
|