Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Search for date in column

  Asked By: Hayrah    Date: Mar 02    Category: MS Office    Views: 749
  

I have the following piece of code which searchs for a specified date
in a worksheet and returns the row number of the date. How would I
alter this code so that only a specified column is searched for the
date in question?

Set rCell = Cells.Find(What:=CDate(strdate), After:=Range("B5"),
LookIn:=xlFormulas, LookAt:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False)
rCell.Select
RowNo = ActiveCell.Row

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Connie Wallace     Answered On: Mar 02

To search  only column  B (for example), maybe something like:

Columns("B:B").Select
Set rCell = Selection.Find(What:=CDate(strdate), After:=Range("B5"), _
LookIn:=xlFormulas, LookAt:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False)
rCell.Select
RowNo = ActiveCell.Row

 
Answer #2    Answered By: Adelino Fischer     Answered On: Mar 02

When you record a macro, the default is always "Cells". You want to change
that to "Range" or "Selection".

 
Didn't find what you were looking for? Find more on Search for date in column Or get search suggestion and latest updates.




Tagged: