CTRL + Fコマンドの実際のコードは何ですか、わかりません。私が見つけた最も近いものが下に貼り付けられます。唯一の問題は、範囲を適切に変更できないことです。VBAのCTRL + Fと似た検索ボックス/ボタン
列Aのシート全体の値を検索する範囲を変更したいのですが、X行の値が見つかったというメッセージを返す代わりに、実際にはそれに行く。私はVBAを初めて使い、アクティブな範囲を理解するのに一番の時間を費やしています。
(GitHubの上)Sub PlayMacro()
Dim Prompt As String
Dim RetValue As String
Dim Rng As Range
Dim RowCrnt As Long
Prompt = ""
' The macro recorder has used the active worksheet. This says which
' worksheet is to be used whether it is active or not. Change "Sheet4"
' to the name of your worksheet.
With Sheets("Sheet4")
' This will loop forever unless a statement within
' the loop exits the Do.
Do While True
RetValue = InputBox(Prompt & "Give me a value to look for")
'RetValue will be empty if you click cancel
If RetValue = "" Then
Exit Do
End If
' I do not wish to active the cell containing the required value.
' I want to know where it is.
Set Rng = .Columns("A:A").Find(What:=RetValue, After:=.Range("A1"), _
LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
If Rng Is Nothing Then
' The entered value could not be found
Prompt = "I could not find """ & RetValue & """"
Else
' The entered value was found
RowCrnt = Rng.Row
Prompt = "I found """ & RetValue & """ on row " & RowCrnt
End If
Prompt = Prompt & vbLf
Loop
End With
コードに問題がありますか? 'Rng'が見つかった場合、' Rng.select'を実行するだけで、値が見つかったセルをアクティブにすることができます。値が3行目の場合は、 'Rng.Row = 3 Then ...'と言うこともできます。シート全体を検索したい場合は、単に 'Set Rng = .Cells.Find(...')を実行します。 – BruceWayne
FWIW 'LookIn:= xlFormulas、LookAt:= xlWhole'は、特にユーザ"xlValues"を見たくないのですか? – YowE3K