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

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
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,979
Messages
6,122,550
Members
449,088
Latest member
davidcom

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