在.VBA函数中查找属于单元格值一部分的文本 [英] Find text which is part of cell value in .Find function VBA excel

查看:44
本文介绍了在.VBA函数中查找属于单元格值一部分的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有如下代码,但是我有问题,我不知道如何找到单元格值中包含SomeText的行.如果我的解释不清楚,例如:SomeText = 1200,并且想要获取单元格值如下的行索引:1200.0和1200.1.在此先感谢您的帮助.

I have code like below, but I have problem, I do not know how can I find row where SomeText is included in cell value. If my explanation is not clear example: SomeText = 1200 and want to get row index where cell value are as follow: 1200.0 and 1200.1. Thanks in advance for any help.

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

推荐答案

只需将 LookAt:= xlWhole 更改为 LookAt:= xlPart

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

这篇关于在.VBA函数中查找属于单元格值一部分的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆