如何用VBA实现在一个sheet中找到一个单元格,并返回它的位置。

2024-11-06 22:27:31
推荐回答(1个)
回答(1):

Sub Macro1()
On Error GoTo 100
Dim aa As String
aa = InputBox("输入需要查找的内容")
Cells.Find(What:=aa, After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, MatchByte:=False, SearchFormat:=False).Activate
MsgBox " Row " & Selection.Row & " / Column " & Selection.Column
Exit Sub
100
MsgBox "查找不到所需内容"
End Sub