设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 9412|回复: 5
打印 上一主题 下一主题

苦求Cells.Find用法

[复制链接]
跳转到指定楼层
1#
发表于 2006-9-29 18:35:00 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
Cells.Find(What:="旧JAN", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
        :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False, MatchByte:=False, SearchFormat:=False).Activate

有没有人可以告诉我Cells.Find 的各个属性值的意思啊,我想在一个页面上搜索一个单元格的内容,然后相对这个单元格做一些处理,

但是搜索的内容叶面上不止有一个,如何利用Cells。find让他搜索到一个就执行处理阿  

高手帮帮忙,不胜感激
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
6#
发表于 2006-12-22 05:45:00 | 只看该作者
Cells.Find(What:="66", After:=ActiveCell, LookIn:=xlFormulas,_ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,_ MatchCase:=False , MatchByte:=False, SearchFormat:=False).Activate

上面是用法,其中“what:=“表示你要查找的内容。可以把它换成用一个字符串来代替,并用inputbox来给字符串赋值,这样可能更智能一点。其他的单词可以查一查他的意思是什么,根据翻译的结果可以慢慢理解怎样使用。

5#
发表于 2006-12-21 05:48:00 | 只看该作者
可以查查资料书!

4#
发表于 2006-12-8 17:07:00 | 只看该作者
非常有用的一个函数,转自国外网站,作用:将含有查找目标数据的单元格并为一个RANGE(类似于按住CTRL选多个区域),然后在VBA中直接对这个RANGE进行操作。

Function Find_Range(Find_Item As Variant, _
    Search_Range As Range, _
    Optional LookIn As Variant, _
    Optional LookAt As Variant, _
    Optional MatchCase As Boolean) As Range
    Dim firstAddress As String
    Dim c As Range

    If IsMissing(LookIn) Then LookIn = xlValues 'xlFormulas
    If IsMissing(LookAt) Then LookAt = xlPart 'xlWhole
    If IsMissing(MatchCase) Then MatchCase = False
     
    With Search_Range
        Set c = .Find( _
        What:=Find_Item, _
        LookIn:=LookIn, _
        LookAt:=LookAt, _
        SearchOrder:=xlByRows, _
        SearchDirection:=xlNext, _
        MatchCase:=MatchCase, _
        SearchFormat:=False)
        If Not c Is Nothing Then
            Set Find_Range = c
            firstAddress = c.Address
            Do
                Set Find_Range = Union(Find_Range, c)
                Set c = .FindNext(c)
            Loop While Not c Is Nothing And c.Address <> firstAddress
        End If
    End With
     
End Function



用法示例
'Here 's just a few of the potential uses for this function...

'Select all cells in a range that contain 22 as part of the value:
Find_Range(22, Range("D10:G20")).Select

'Clear the range if the cell contains exactly 999, but if it's a formula leave it be:
Find_Range(999, Range("D10:G20"), xlFormulas, xlWhole).ClearContents

'Delete all rows that contain "X" in column A:
Find_Range("X", Columns("A"), MatchCase:=True).EntireRow.Delete

'Quickly scan the whole sheet if you like!
Find_Range(1000, Cells, xlFormulas, xlWhole).EntireRow.Select

'Copy all the rows that have the value 1000 in column D and paste to Sheet2:
Find_Range(1000, Columns("D"), xlFormulas, xlWhole).EntireRow.Copy Range("Sheet2!A1")
3#
发表于 2006-12-8 02:44:00 | 只看该作者
怎么才能查看cells.find的帮助呢?我在帮助索引里输入cells没有用
2#
发表于 2006-9-30 02:59:00 | 只看该作者
看帮助
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-9-22 05:38 , Processed in 0.103535 second(s), 30 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表