View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
GS[_6_] GS[_6_] is offline
external usenet poster
 
Posts: 1,182
Default A Boolean expression

Hi Garry,

Am Sun, 26 Apr 2015 14:30:25 -0400 schrieb GS:

For n = 1 To Selection.Cells.Count


IMO For each ... is faster than
For n = 1 to ...
What's your opinion about loops?


Regards
Claus B.


I was only trying to demo a clean way to do 'With Selection' to Howard.
I might have gone with...


Sub CellColLetter2() '//Ctrl+Q
Dim c
For Each c In Selection
c.Interior.ColorIndex = IIf(c.Interior.ColorIndex < 6, 6, xlNone)
c = IIf(c.Interior.ColorIndex = 6, "A", Empty)
Next 'c
End Sub

...because of its brevity. Given that we don't know the size of
'Selection' in the real file it's hard to say which is fast. My opinion
is that it depends on the scenario. In my test of a 10 x 10 block of
cells the results were instantaneous!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion