Martin Perera
Board Regular
- Joined
- Jan 17, 2005
- Messages
- 147
Hi guys
I am somewhat confused, I seem to be having difficulty passing a variable to .Find.
this bit of code works as it should
however when I try to pass the date as a variable it finds the last entry in the row then sets the range.
I do not understand why this is happening any one got any ideas.....
cheers
martin
I am somewhat confused, I seem to be having difficulty passing a variable to .Find.
this bit of code works as it should
Code:
Sub FindDate()
Dim dDate As Date
Dim c As Range
'need to pass the date to sub as a variable.. how what sort?
dDate = Range("d1").Value
With Worksheets(1).Range("A10:AG10") 'range with dates
Set c = .Find("20/03/05") 'find this date in row 10
Range(c.Offset(1, 0), c.Offset(33, 27)).Select 'range just below selected date
End With
End Sub
however when I try to pass the date as a variable it finds the last entry in the row then sets the range.
Code:
Sub FindDate()
Dim dDate As Date
Dim c As Range
'need to pass the date to sub as a variable.. how what sort?
dDate = Range("d1").Value
With Worksheets(1).Range("A10:AG10") 'range with dates
Set c = .Find(dDate) 'find this date in row 10 goes to end of row?
Range(c.Offset(1, 0), c.Offset(33, 27)).Select 'range just below selected date
End With
End Sub
I do not understand why this is happening any one got any ideas.....
cheers
martin