PDA

View Full Version : [SOLVED] excel vba search text in range and retrieve results in a textbox



Alex Roth
09-13-2016, 06:14 AM
This macros is working, but I want to display results from a range D2:82 in text box without automatically redirection user to the located text. When it comes to VBA, I am a very basic user.I realize I may be asking a question already asked and answered in a different thread so I apologize about that. Help me please change my macros?

Sub Button 1_Click()

Res = InputBox("Who are you looking for?")
Set Rng = Worksheets("Level2").Range("B2:B82")'<< The Sheet Name and Range to Search

With Rng
Set MyChoice =.Find(What:=Res)

IfNot MyChoice IsNothingThen
Application.Goto MyChoice
Else:GoTo ExitMyChoice

EndIf

EndWith
ExitSub

ExitMyChoice:
MsgBox "Could Not Find "& Res

EndSub

SamT
09-13-2016, 11:40 AM
but I want to display results from a range D2:82 in text box


Sub Button 1_Click()

Res = InputBox("Who are you looking for?")
Set Rng = Worksheets("Level2").Range("B2:B82") '<< The Sheet Name and Range to Search

With Rng
Set MyChoice =.Find(Res)

If Not MyChoice Is Nothing Then
MsgBox Res
Else
MsgBox "Could Not Find " & Res
EndIf

EndSub

Alex Roth
09-14-2016, 05:30 AM
run a macro:Compile error:
Sub or Function not defined

SamT
09-14-2016, 07:11 AM
endsub