(6条消息) VBA中find函数_狗老大的博客-CSDN博客_vba find函数
Sub test1() ' Dim r As Range Dim s As String s = "Hello" Dim a As Range '查找第一个内容含有vba的单元格 'Set r = Worksheets(1).Cells.Find("vba") '查找第一个内容精确为vba的单元格 'Set r = Worksheets(1).Cells.Find(what:="vba", lookat:=xlWhole) '查找第一个包含大写字母"VBA",且单元格为红色的的单元格 'Application.FindFormat.Interior.Color = vbRed 'Set r = Worksheets(1).Cells.Find(what:=s,lookat:=xlPart, MatchCase:=True, Searchformat:=True) '找到第一个内容为“GWb”的单元格,并且大小写精确匹配。 Set r = Range("I13") Do Set r = Worksheets(1).Cells.Find(what:=s, after:=r, lookat:=xlPart, MatchCase:=False, Searchformat:=False, LookIn:=xlValues) r.Interior.Color = vbBlue ' Set r = Worksheets(1).Cells.Find(what:=s, after:=a, lookat:=xlPart, MatchCase:=True, Searchformat:=False, LookIn:=xlFormulas) MsgBox (r.Address()) If r.Address = "$I$13" Then Exit Do Loop While Not r Is Nothing MsgBox (r.Address()) End Sub
标签:vba,Set,Cells,单元格,Find,Worksheets,find From: https://www.cnblogs.com/Insist-Y/p/17021109.html