打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Vba中Find方法使用总结(一)
Sub findNum()
    Dim r As Range
     
    Set r = Cells.Find('熊猫')
     
    If Not r Is Nothing Then
        r.Interior.Color = vbRed
    End If
End Sub
Sub findNum1()
    Dim r As Range
     
    Set r = Cells.Find(2, lookat:=xlWhole, searchorder:=xlRows)
     
    If Not r Is Nothing Then
       r.Interior.Color = vbRed
    End If
     
End Sub
Sub findNum2()
  Dim r As Range
  Set r = Cells.Find(2, lookat:=xlWhole, searchorder:=xlRows)
   
  If Not r Is Nothing Then
     r.Interior.Color = vbRed
  End If
   
  Do While Not r Is Nothing
   
    Set r = Cells.Find(2, after:=r)
     
    If Not r Is Nothing Then
       r.Interior.Color = vrRed
    End If
     
  Loop
   
End Sub
Sub findNum3()
   Dim r As Range
   Set r = Cells.Find(2, lookat:=xlWhole, searchorder:=xlRows)
    
   Do While Not r Is Nothing
      r.Interior.Color = vbRed
      '程序进入了死循环'
      Set r = Cells.Find(2, after:=r)
      '判断是不是第一次的单元格'
      If r.Address = '$C$2' Then Exit Do
       
    Loop
       
End Sub
Sub findNum4()
   Dim r As Range, s As String
    
   Set r = Cells.Find(2, lookat:=xlWhole, searchorder:=xlRows)
   If Not r Is Nothing Then
       s = r.Address
   End If
    
   Do While Not r Is Nothing
      r.Interior.Color = vbRed
      Set r = Cells.Find(2, after:=r)
      If r.Address = s Then Exit Do
   Loop
End Sub
Sub findNum5()
  Dim r As Range, s As String
  Set r = Cells.Find(2, lookat:=xlWhole, searchorder:=xlRows)
  If Not r Is Nothing Then
     s = r.Address
     'do while 循环'
     Do
       r.Interior.Color = vbRed
       Set r = Cells.Find(2, after:=r)
     Loop While r.Address <> s
   
  End If
End Sub
Sub findNum6()
  Dim r As Range, s As String
  Set r = Cells.Find(2, lookat:=xlWhole, searchorder:=xlRows)
  If Not r Is Nothing Then
     s = r.Address
     'do while 循环'
     Do
       r.Interior.Color = vbRed
       Set r = Cells.Find(2, after:=r)
       '不断循环,知道r的地址是s时终止'
     Loop Until r.Address = s
   
  End If
End Sub
Sub findNum7()
  Dim r As Range, s As String
  Set r = Cells.Find(2, lookat:=xlWhole, searchorder:=xlRows)
  If Not r Is Nothing Then
     s = r.Address
     'do while 循环'
     Do
       r.Interior.Color = vbRed
       Set r = Cells.FindNext(r)
       '不断循环,知道r的地址是s时终止'
     Loop Until r.Address = s
   
  End If
End Sub
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
excel-vba 查找 标色 替换
VBA-FIND方法 的运用
[VBA]关于查找方法(Find方法)的应用示例补充
Excel 怎么样用VBA做订单录入
工作中经常用到的VBA代码推荐
vba分组
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服