J
Jeffrey Harris
I have the following function
Function GetRowWithDate(aDate As Date) As Range
dateRange = Worksheets("Prices").Range("A3:A" &
Worksheets("Prices").UsedRange.Rows.Count)
For Each cell In dateRange
If cell = aDate Then
Set GetRowWithDate = Worksheets("Prices").Range("A" & cell.Row &
"" & cell.Row) <-- line with error.
Exit Function
End If
Next cell
Set GetRowWithDate = Nothing
End Function
When I call the function by 'oldDate = GetRowWithDate("10/27/03")' I get a
"Run-time error '404': Object required" error on the line I've flagged. I'm
new to VBA programming, what concept am I not understanding? And how do I
get this to return the range?
Function GetRowWithDate(aDate As Date) As Range
dateRange = Worksheets("Prices").Range("A3:A" &
Worksheets("Prices").UsedRange.Rows.Count)
For Each cell In dateRange
If cell = aDate Then
Set GetRowWithDate = Worksheets("Prices").Range("A" & cell.Row &
"" & cell.Row) <-- line with error.
Exit Function
End If
Next cell
Set GetRowWithDate = Nothing
End Function
When I call the function by 'oldDate = GetRowWithDate("10/27/03")' I get a
"Run-time error '404': Object required" error on the line I've flagged. I'm
new to VBA programming, what concept am I not understanding? And how do I
get this to return the range?