Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Problems with Find in VBA/Excel
I posted this to another excel group, but neither of the responses I had did
any good. I'm trying to get data from the cells to the right of the date column in a 10 column table sorted by date. This is the code that I'm trying to use: Sub KSBLookup() Dim vResult As Range Dim datein As Date datein = InputBox("Enter Target Date") If datein 0 Then datein = DateValue(datein) End If MsgBox "Date = " & datein If WorksheetFunction.CountIf(Sheet1.Range("Data"), datein) 0 Then With Sheet1.Range("Data") Set vResult = .Find(What:=(datein), After:=.Cells(1, 1), SearchOrder:=xlByRows, SearchDirection:=xlNext).Offset(0, 2) End With MsgBox vResult.Value End If End Sub As you may guess, I am getting error 91. Do I need to declare the range name itself as a variable? The entiore set of values is the range. The values in the columns other than the date column are integers. I have tried several things - but get the same error most of the time,k and the error isn't telling me anything. On mouseover, vResult appears empty. The message boxes are in only to tell me if I am getting the correct result. I have taken out the If statement (and its corresponding End If) but this does not help either. Any help on this would be appreciated.. Roy |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Find duplicate rows then deleting them | Excel Worksheet Functions | |||
How do I compare data in two worksheets to find matching cells? | Excel Discussion (Misc queries) | |||
Excel has a "Find Next" command but no "Find Previous" command. | Excel Discussion (Misc queries) | |||
Find & Replace results to display specified chosen fields | Excel Discussion (Misc queries) | |||
"Find All" | Excel Discussion (Misc queries) |