Simple find row containing date

keaveneydan

Board Regular
Joined
Apr 29, 2014
Messages
144
Why won't this work? I would like to find in Column A the date contained in a certain cell.

If I set the range to be activeSheet and all Cells I get a random row returned....row 649

Thanks for any help
Code:
Sub LastUsedRow_Find()
 
'FIND method to determine Last Row with Data, in a worksheet
 
Sheets("HSBC Fees update daily").Select
 
ValuationDate = Sheets("Net Assets").Range("C3").Value
Dim lastRow As Long
 
Dim rng As Range
 
Set rng = ActiveSheet.Columns(1)
 
lastRow = rng.Find(What:=ValuationDate, After:=rng.Cells(1), Lookat:=xlPart, LookIn:=xlFormulas, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False).Row
 
 
 
MsgBox lastRow
 
 
 
End Sub
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
What do you mean work? Looks like its ok to me. Needs error handler in case the find fails.
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,695
Members
448,979
Latest member
DET4492

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