首页 > 解决方案 > 检查是否在 VBA 列中找到多个列出的值

问题描述

如果在 A 列中找不到所有三个值,我想确保在 A 列中找到值 PF、AD、FF 显示错误。我的代码在下面请帮助我。

Sub Check_All()
Dim sht As Worksheet
Dim c As String
Dim d As String
Dim e As String
Dim lastrow As Long
Dim i As Long
Dim mycell As Range
Set sht = Sheets("sheet4")
lastrow = sht.Range("A" & Rows.Count).End(xlUp).Row
c = "PF"
d = "AD"
e = "FF"
Set mycell = sht.Range("A2:A" & lastrow).Find(what:=c & d & e, LookIn:=xlValues)
If mycell Is Nothing Then

Else

  MsgBox "Error"
End If
Exit Sub

End Sub

标签: excelvba

解决方案


推荐阅读