Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Albert Smith   on Nov 03 In MS Office Category.

  
Question Answered By: Cadencia Bernard   on Nov 03

The commented-out part of your code is setting a variable with a range  of
rows that represent what you want to work  through.

The later part of your code works  with "Selection".

You have never actually selected  the area you found, so it's working with
whatever selection  you had when you entered the code.

Instead of Selection, use rngToSearch, and it'll probably work. Or do a
select of rngToSearch.

The reason it works backwards is that if you worked forwards you would have
to compensate for the situation of two consecutive blank rows. I.e. (say
they're 10 and 11)

i = 10 (set by your For statement)
row (i) is blank, delete it, row  11 moves to row 10
"Next i" - i is now 11
row(i) is not blank (remember it was row 12 originally)
etc

Working backwards eliminates this problem. I.e. delete row 11. Row 10
stays where it is. "Next i" now moves to 10.

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on modify a macro to find the selected range Or get search suggestion and latest updates.


Tagged: