vba-在特定列中查询目标字符串是否存在

Private Sub SearchByTaget()
   If ConfigSht.Range("A:A").Find(What:="1232", LookAt:=xlWhole) Is Nothing Then
   MsgBox "不存在"
   End If
End Sub


Function SearchByTarget(ByVal range as Range, ByVal target as String) as Boolean
   If range.Find(What:=target, LookAt:=xlWhole) Is Nothing Then
    SearchByTarget = false
  else
  SearchByTarget = true End If End Sub
 

 优化下,这个可以把一列存进字典

posted @ 2022-12-04 19:21  vba是最好的语言  阅读(437)  评论(0编辑  收藏  举报