1
我的代码的每个部分都工作到目前为止,我只想编辑一个部分。我有我的宏搜索过滤范围,看看它是否包含“检入”和“签出”。如何筛选过滤范围以查看是否有单元格包含某些文本
但是我想添加更多的单词来检查。有没有什么办法可以改变这个代码,或许可以创建一个字符串数组,用于搜索每个单元格?
我想我可以添加很多“if或者”,但那并不好玩。
Sub checkk()
Dim cl As Range, rng As Range
Dim LastRow As Long
Dim celltxt As String
Dim i As Integer
i = 1
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
Set rng = Range("A1:A" & LastRow)
For Each cl In rng.SpecialCells(xlCellTypeVisible)
cl.Select
celltxt = ActiveCell.Text
If InStr(1, celltxt, "CHECKED OUT") Or InStr(1, celltxt, "CHECKED IN") Then
MsgBox ("found it")
else
MsgBox ("no")
End If
Next cl
If i > 1 Then
MsgBox ("Looks like you have to do some more filtering, sort column A by
color to see what was tagged")
End If
End Sub
[词组中的数量和高亮关键字(可能的重复https://stackoverflow.com/questions/32860792/count-和 - 突出显示关键字内短语)和/或[模式匹配在Excel中](https://stackoverflow.com/questions/32946884/pattern-matching-in-excel)。 – Jeeped