Run time error '91' while performing a "Find"

Newbi

New Member
Joined
Apr 24, 2009
Messages
12
Hey all,

I'm trying to streamline a macro that was given to me by a colleague. In it, one of the tasks is to find the maximum value from a long list of data and then do some calculations on it.
The original has one cell at the top of the list that uses the "=Max" function in it to find the value of the maximum but I need to know what row it is in. I used the following code to find the row number write it in a cell. The FindData variable is assigned to the maximum value.

Sub FindCells()

Dim FindData As Double
Dim Row_Number As Integer


FindData = ActiveSheet.Cells(6, 15).Value
Range("L5:L2000").Find(What:=FindData, After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate

Row_Number = ActiveCell.Row
ActiveSheet.Cells(2, 14).Value = Row_Number

End Sub

If FindData is used as a "Long" data type the code runs, but it doesn't necessarily return the maximum value, just a value that happens to contain some of the maximum values digits. I need the find function to return exactly the value that's assigned to the FindData variable. The maximum value is a rational number with several decimal places.

Any help would be great!

Thanks!
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Nah, that didn't work.

I'm getting a Run time error '13' now though.

I'm not really sure what that means either though.
 
Upvote 0

Forum statistics

Threads
1,214,644
Messages
6,120,709
Members
448,983
Latest member
Joaquim_Baptista

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