[英]Check if a cell contains specific text
I have to put jobs from one spreadsheet onto another in their priority order. 我必须将作业从一个电子表格按优先级顺序放在另一个电子表格上。 If a job is listed as completed, then I do not transfer that job over.
如果某项工作被列为已完成,那么我不会将该工作转移过来。 Below is my code for the top priority, "priority 1".
以下是我的最高优先级代码“优先级1”。 The cell that states it's completion status sometimes has a date before or after it, which is why I put the "*" character.
指出完成状态的单元格有时在其前后都有一个日期,这就是为什么我要输入“ *”字符。
Do Until IsEmpty(ActiveCell) Or count > 14
If ActiveCell.Value = "Priority I" Then
ActiveCell.Offset(0, 6).Select
If ActiveCell.value = "completed" like "*completed*" Then
ActiveCell.Offset(1, -6).Select
Else
ActiveCell.Offset(0, -1).Select
word0 = ActiveCell.Value
ActiveWindow.ActivateNext
ActiveCell = word0
ActiveWindow.ActivateNext
ActiveCell.Offset(0, -9).Select
word = Left(ActiveCell.Value, 6)
ThisWorkbook.Activate
ActiveCell.Offset(0, 1).Select
ActiveCell = word
ActiveWindow.ActivateNext
ActiveCell.Offset(0, 1).Select
word1 = ActiveCell.Value
ThisWorkbook.Activate
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = word1
ActiveWindow.ActivateNext
ActiveCell.Offset(0, 1).Select
word2 = ActiveCell.Value
ThisWorkbook.Activate
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = word2
ActiveWindow.ActivateNext
ActiveCell.Offset(0, 1).Select
word3 = ActiveCell.Value
ThisWorkbook.Activate
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = word3
ActiveCell.Offset(1, -4).Select
ActiveWindow.ActivateNext
ActiveCell.Offset(1, 1).Select
count = count + 1
End If
Else
ActiveCell.Offset(1, 0).Select
End If
Loop
I have confirmed that it is checking the correct column, it just doesn't catch the word completed. 我已经确认它正在检查正确的列,只是没有抓住完成词。 So the problem resides within that line, line 4.
所以问题出在第四行。
Change 更改
If ActiveCell.value = "completed" like "*completed*" Then
to 至
If Instr(1, UCase(ActiveCell.Value), "COMPLETED") > 0 Then
or 要么
If UCase(ActiveCell.Value) like "*COMPLETED*" Then
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.