Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Web resources for use of SpecialCells and Intersect

Hi All

From reading this group and some of the MVP web sites I have come

across the use of SpecialCells and Intersect as the most efficient way
to loop through data in Excel VB logic.

What I have not found is a concise explanation of why this is so and
what exactly best practice is.

Can anyone point me to some good web resources that discuss the use of
SpecialCells and Intersect?

Cheers
Chrisso

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Web resources for use of SpecialCells and Intersect

On Mar 2, 6:08 am, "Chrisso" wrote:
Hi All

From reading this group and some of the MVP web sites I have come


across the use of SpecialCells and Intersect as the most efficient way
to loop through data in Excel VB logic.

What I have not found is a concise explanation of why this is so and
what exactly best practice is.

Can anyone point me to some good web resources that discuss the use of
SpecialCells and Intersect?

Cheers
Chrisso


Try the following:

http://www.mvps.org/dmcritchie/excel/proper.htm

-Tim

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Web resources for use of SpecialCells and Intersect

If you are using special cells, then there probably is not need to loop
through all cells - only cells that meet a specific criteria that can be
culled out by using special cells. So if say , column A contained constants
and formulas and you wanted to loop through just the formulas:

for each cell in columns(1).specialcells(xlFormulas)

The only advantage is that it reduces the number of cells that have to be
looked at and you don't have to test each cell to see if it contains a
formula. You already know it does, because you are only looking at cells
that contain fomrulas.

I wouldn't see it being any more involved than that. As to intersect,
again, it is a method to reduce the number of cells looked at. When used
with specialcells it is often used to correct a situation where you issue
specialcells and only one cell is usd to qualify the command. In that case,
specialcells will examine the entire usedrange of the worksheet. this is
only a problem is your code can't know in advance whether the range anchor is
one or multiple cells.

Public function Myfunc(rng1 as Range)
Dim rng as Range
set rng = Intersect(rng1,rng1.specialcells(xlConstants))
set myfunc = rng
End Function


if rng1 refers to a single cell, then rng1.specialcells(xlConstants) could
return many cells outside the calling routines interest. Using the intersect
culls it back down to the range of interest.
--
Regards,
Tom Ogilvy


"Chrisso" wrote:

Hi All

From reading this group and some of the MVP web sites I have come

across the use of SpecialCells and Intersect as the most efficient way
to loop through data in Excel VB logic.

What I have not found is a concise explanation of why this is so and
what exactly best practice is.

Can anyone point me to some good web resources that discuss the use of
SpecialCells and Intersect?

Cheers
Chrisso


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Intersect Arne Hegefors Excel Programming 1 July 25th 06 09:38 AM
Intersect [email protected] Excel Programming 2 July 19th 06 10:41 PM
intersect and combo box scrabtree[_2_] Excel Programming 1 September 15th 04 06:49 PM
Intersect with decimal Nicke Excel Programming 0 November 20th 03 02:02 PM
Help with If Not Intersect derek Excel Programming 6 July 11th 03 04:39 PM


All times are GMT +1. The time now is 11:04 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"