希望在测试这条路上可以走得很远
vba-excel之查找字串
上一篇 /
下一篇 2015-03-19 21:50:11
/ 个人分类:vba
字串查找:Find/FindNext/FindPrevious
.Find(What, After, LookIn, LookAt, SearchOrder, SearchDirection, MatchCase, MatchByte, SearchFormat)
what表示待搜索的数据;
After表示搜索过程将从其之后开始进行的单元格;
LookIn表示信息类型,包括xlValues(值)、xlFormulas(公式)(默认值)或者xlComments(批注)
LookAt表示匹配方式,包括xlWhole(单元格匹配)、xlPart(字符匹配)(默认)
SearchOrder表示查询顺序,包括xlByRows,xlByColumns
SearchDirection表示搜索的方向,包括xlNext、xlPrevious
MatchCase:为TRUE表示区分大小写,默认为false
FindNext:继续由Find方法开始的搜索,后面参数(Range对象)表示从该单元格之后开始;若未指定,则从区域的左上角单元格之后开始;
FindPrevious:继续由FInd方法开始的搜索,后面参数(Range对象)表示从该单元格之后开始;若未指定,则从区域的左上角单元格之后开始;
tStr=ActiveSheet.UsedRange.Cells.Find(what:="待查找字符串",LookIn:=xlValue)
FirstAddress = tStr.Address
Do
tRowNum = tStr.Row
tColNum = tStr.Column
tStr = ActiveSheet.UsedRange.Cells.FindNext(tStr)
Loop while Not tStr is Nothing And tStr.Address <> FirstAddress
收藏
举报
TAG: