我一直在尝试几种不同的方法来查找bingo(由星号列出和分隔)的行号,但似乎都没有.我究竟做错了什么?在所有情况下,我都试过寻找Bingo和"Bingo".
Sub Find_Bingo()
Dim wb As Workbook
Dim ws As Worksheet
Dim FoundCell As Range
Set wb = ActiveWorkbook
Set ws = ActiveSheet
Const WHAT_TO_FIND As String = "Bingo"
Set FoundCell = ws.Range("A").Find(What:=WHAT_TO_FIND)
If Not FoundCell Is Nothing Then
MsgBox (WHAT_TO_FIND & " found in row: " & FoundCell.Row)
Else
MsgBox (WHAT_TO_FIND & " not found")
End If
'************
With Sheet1
Set FoundCell = Cells.Find(What:=Bingo, After:=.Cells(1, 1), _
LookIn:=xlValues, lookat:= xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Activate
End With …Run Code Online (Sandbox Code Playgroud)