selection.find shortening the procedure by skipping the "activate" part

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

Hello everyone,

In a macro I have this piece of code of which I know a shorter version can
be implemented (but I don't know how exactly). It has to do something with
omitting the "activate" part of it, and directly placing the desired values
(the row and column numbers) into the variables, I believe by using the Set
statement. Exactly how, I'd like to know from you:

Code:
For Element = 1 To UBound(IDs)
Range("B3:B1000").Select
Selection.Find( _
What:=IDs(Element), _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False).Activate

r = ActiveCell.Row

Rows(2).Select
Selection.Find( _
What:=Month, _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False).Activate

c = ActiveCell.Column

usage: both win xp/office 2003 (home) and
win2000 / office2000 (at the office)

TIA,
Peter.
 
Peter


Is this what you are after


r = Range("B3:B1000").Find( _
What:=IDs(Element), _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False).Ro
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top