Excel VBA "After" property in Find

Hi
I am a little confused by the After property in find
If I want to find a value on the whole spreadsheet and I use After:=Range("A1")
will "A1" be included in the search?


   Cells.Find(What:="Budget Vs Actual 2015", After:=Range("A1"), LookIn:= _
        xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
        xlNext, MatchCase:=False, SearchFormat:=False).Activate
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
No. Imagine it to be the result of a prior search - you don't want it to be included in the search.
0
 
ProfessorJimJamCommented:
It won't search A1
Instead use cell. Count method
0
 
ProfessorJimJamCommented:
After:=.cells(.cells.count) like this
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
ProfessorJimJamCommented:
.Find(What:="budget vs actual", _ After:=.Cells(.Cells.Count), _ LookIn:=xlFormulas, _ LookAt:=xlPart, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False)
0
 
Saqib Husain, SyedEngineerCommented:
Yes, if that address is included in the range to be searched.

This address would be returned if no other cell contains the value to be searched.
0
 
Martin LissOlder than dirtCommented:
After:= is not required, so just leave it out.
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks
0
 
Saqib Husain, SyedEngineerCommented:
There is one answer which says No and another which says Yes. How can both be correct?
0
 
Martin LissOlder than dirtCommented:
There is one answer which says No and another which says Yes. How can both be correct?
I assume the asker was just being kind, and spreading the points between everyone who contributed.
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
The correct answer is a mixture of both http:#a40707050 and http:#a40707058:
No, unless there is no other cell containing the value to be searched.

Martin's comment is correct, too - no need to use After if the cell should be included in the search.
But I cannot see how http:#a40707052 can be of any use.
0
 
ProfessorJimJamCommented:
Martin,

 if my post wasn't of any use, then i do not need free points. please remove the points from my answer.

besides, perhaps i misunderstood the question, or otherwise my answer was useful to the OP.
0
 
Martin LissOlder than dirtCommented:
Martin, ...please remove the points from my answer.
I'm only a lowly cleanup volunteer so I don't have that ability. If you really don't want the points you could 'Request Attention' to this thread and a moderator might oblige you.
0
 
ProfessorJimJamCommented:
if it is too much trouble, then i wont bother.

thanks Martin
0
 
Martin LissOlder than dirtCommented:
While I think I'd get points in either case (and more if the Professor's answer wasn't included), I think we should just leave it the way the Asker closed it.
0
 
Saqib Husain, SyedEngineerCommented:
The question was
will "A1" be included in the search?

The answer should either be a Yes or a No, not both. We cannot leave the answers as-is for future readers.
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Some questions cannot be answered with yes or no only. Sometimes "it depends" is correct
0
 
Saqib Husain, SyedEngineerCommented:
You can reject both but not select both.
0
 
Martin LissOlder than dirtCommented:
I think that unless it's grossly the wrong action that the user can do whatever he wants. I'm sure that I could find more than one question where one of the accepted answers was questionable.

I'll say no more here.
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
To clarify, the answers are not opposites and not simply Yes or No. There is definite overlapping and the advice was useful from all of you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.