Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Roy Kirkland
 
Posts: n/a
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find duplicate rows then deleting them SSHO_99 Excel Worksheet Functions 4 May 4th 07 11:17 AM
How do I compare data in two worksheets to find matching cells? Gary Excel Discussion (Misc queries) 4 March 2nd 06 09:04 PM
Excel has a "Find Next" command but no "Find Previous" command. Michael Fitzpatrick Excel Discussion (Misc queries) 2 January 10th 05 11:45 PM
Find & Replace results to display specified chosen fields samuel Excel Discussion (Misc queries) 1 December 28th 04 08:43 AM
"Find All" DavidB Excel Discussion (Misc queries) 1 December 21st 04 03:56 PM


All times are GMT +1. The time now is 07:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"