PDA

View Full Version : Run Time Errror 91 when trying to find value



acertco03dis
06-16-2016, 06:35 AM
Hello,

When I try to run the following piece of code, I am getting a run time error saying the object variable was not defined. I know for a fact that the value in A32 matches something on Sheet1, yet I am still getting the error saying that nothing was found. Any ideas? Thanks.



Dim EmployeeName As String




Worksheets("Admin").Activate
Range("A32").Select
EmployeeName = ActiveCell.Value

Worksheets("Sheet1").Activate
Range("A8", "A1000").Find(EmployeeName).Select

mikerickson
06-16-2016, 06:44 AM
Try

Range("A8:A1000").Find(EmployeeName).Select

acertco03dis
06-16-2016, 06:48 AM
Unfortunately, that didn't work.

Paul_Hossler
06-16-2016, 07:08 AM
1. try this, and if it still doesn't work post a small sample

2. Make sure Sheet1 exists

3. Make sure there are no leading or trailing spaces in A32 or A8:A1000





Dim EmployeeName As String

EmployeeName = Worksheets("Admin").Range("A32").Value

Worksheets("Sheet1").Select ' note the .Select
Range("A8":A1000").Find(EmployeeName).Select ' note the colon

acertco03dis
06-16-2016, 07:38 AM
That seemed to do the trick. Thanks for the help!

mikerickson
06-16-2016, 05:13 PM
Paul

Why the first quotation mark?


Range("A8":A1000").Find(EmployeeName).Select ' note the colon

Paul_Hossler
06-16-2016, 05:38 PM
Paul

Why the first quotation mark?



Because I messed up

If I had tested it or at least compiled it, I would have found it

snb
06-17-2016, 04:34 AM
Sub M_snb()
sheets("Sheet1").cells(8,1).resize(992).Find(sheets("Admin").cells(32,1).value,,,1).Select
End Sub

mikerickson
06-17-2016, 06:06 AM
Or


Application.Goto Sheets("Sheet1").Range("A8":A1000").Find(EmployeeName)

Paul_Hossler
06-17-2016, 06:23 AM
without the first quotation mark of course :devil2: