Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Matthew Bouchard   on Aug 16 In MS Office Category.

  
Question Answered By: Fabia Ferrrari   on Aug 16

There are quite a few usages of the With item in the cod, including in the
second With statement itself.

Every time  you see a full-stop preceded by a space it will be using a With.
In this case, the two With clauses are:

With shtData.Range("A2").CurrentRegion.Columns(1)
With .SpecialCells(xlCellTypeVisible)

So, the first With stops the need to repeat
shtData.Range("A2").CurrentRegion.Columns(1) several times, and the second
With stops the need to repeat
shtData.Range("A2").CurrentRegion.Columns(1).SpecialCells(xlCellTypeVisible)
several times.

This shortens the code  considerably and also assists the VBA engine to
create a temporary reference and use that - thereby speeding up execution
too.

The item you are checking the areas count  on is
.SpecialCells(xlCellTypeVisible) which is the visible cells  after the filter
has been created. The filter has presumably filtered out one or more rows.
(As the count is 2, I'd assume that there is only one gap.)

The area  you are checking is one column wide, so I can also assume that one
of the two visible areas (I don't know which one, because you haven't said
what "j" is when the count equals 2) is two rows high.

Share: 

 
 
Didn't find what you were looking for? Find more on Areas Collection Question Or get search suggestion and latest updates.


Tagged: