Find a response

tiredofit

Well-known Member
Joined
Apr 11, 2013
Messages
1,834
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I am trying to ask the user to enter a string to find.

Code:
    Dim Response As String
  
    Response = Application.InputBox(Prompt:="Enter a value", Type:=2)
  
    Dim Found As Range
  
    Set Found = Sheet1.Range("A1:A100").Find Response

I am trying to capture the response but it fails on the last line.

How can I correct it?

Thanks

EDIT SORTED:

Code:
Set Found = Sheet1.Cells.Find(What:=Response, After:=Sheet1.Cells(1, 1), _
            LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, _
            SearchDirection:=xlNext, MatchCase:=False)
 
Last edited:

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
but it fails on the last line.
In what way? error? Finds wrong value? Finds nothing? etc

Quite likely an issue that you are not specifying other parameters of Find. eg whether to match whole cell or part of cell, whether to match case etc.

Range.Find method (Excel)

Syntax​

expression.Find (What, After, LookIn, LookAt, SearchOrder, SearchDirection, MatchCase, MatchByte, SearchFormat)
 
Upvote 0
Looks like you have it under control now. (y)
 
Upvote 0
Try this Code:
Dim Response As String

Response = Application.InputBox(Prompt:="Enter a value", Type:=2)

Dim Found As Range

Set Found = Sheet1.Range("A1:A100").Find ("Response")
 
Upvote 0

Forum statistics

Threads
1,215,446
Messages
6,124,895
Members
449,194
Latest member
JayEggleton

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top