如何在整个工作表中查找包含string的单元格

我想在包含特定string的工作表中find一个单元格。

我不知道电子表格中有多less列或行,因此我想用CurrentRegion来做。

这就是我想要的:

 =FIND("Data String", Range("A1").CurrentRegion) 

您应该看看Microsoft参考: Range.Find方法(Excel) 。

  .Find(What, After, LookIn, LookAt, SearchOrder, SearchDirection, MatchCase, MatchByte, SearchFormat) 

例:

 Dim rngFound as Range With Worksheets("MySheetName").Cells Set rngFound = .Find("MySearchString", LookIn:=xlValues) If Not rngFound Is Nothing Then 'something is found else 'nothing found End If End With 

search整个表格

尝试这个

  FindString = Sheets("Sheet1").Range("D1").Value 

———-这将使用inputinputbox值来select范围内的下一个Cell

 Sub Find_First() Dim FindString As String Dim Rng As Range FindString = InputBox("Enter a Search value") If Trim(FindString) <> "" Then With Sheets("Sheet1").Range("A:A") Set Rng = .Find(What:=FindString, _ After:=.Cells(.Cells.Count), _ LookIn:=xlValues, _ LookAt:=xlWhole, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False) If Not Rng Is Nothing Then Application.Goto Rng, True Else MsgBox "Nothing found" End If End With End If End Sub 

find价值