2015-08-19 48 views
1

我有类似下面的代码,但我遇到了问题,我不知道如何查找其中SomeText包含在单元格值中的行。如果我的解释不清楚例子:SomeText = 1200并且想得到行索引,其中单元格值如下:1200.0和1200.1。预先感谢您的帮助。查找属于单元格值的文本。查找函数VBA excel

Set cell1 = Selection.Find(What:=SomeText, After:=ActiveCell, LookIn:=xlValues, _ 
    LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ 
    MatchCase:=False, SearchFormat:=False) 
+1

你有没有试图改变'xlWhole'到'xlPart'? – Bond

回答

1

只要改变LookAt:=xlWholeLookAt:=xlPart

Set cell1 = Selection.Find(What:=SomeText, After:=ActiveCell, LookIn:=xlValues, _ 
    LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ 
    MatchCase:=False, SearchFormat:=False)